• I would like to exclude image titles from search results. For instance, if I have an image called image-wikipedia.jpg, right now, if I search for Wikipedia the story that uses that image is returned in the results.

    I tried the Simply Exclude plugin and Relevanssi plugin, but neither worked. I don’t know if it’s because I am using a custom search results page that these plugins aren’t working.

    Any help would be much appreciated. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • I would like to exclude image titles from search results

    Why? Don’t like traffic and ranking from image links? Or, do you want to hide the identity of images?

    Thread Starter donnytree

    (@donnytree)

    Because the image title does not necessarily have anything to do with the search. For instance, in my above example, I may label an image I got from Wikipedia with the source name, but that doesn’t mean I want it in search results if someone is looking for an article about Wikipedia. It is for an article-based research website so it is the nature of the information I am trying to deliver.

    It is for an article-based research website so it is the nature of the information I am trying to deliver.

    Good enough! Then will it not be a nice thing to name the image relevant to your research topic and get the benefit of image search also coming to your site? Well, if you don’t want that just give it some random numbers and characters as the image name.

    Now about images from Wikipedia: unless you use the links generated by Wikipedia and use the licenses under which you use them, you do not need to use the name Wikipedia. If you use images other than PD images/ CC0 images, still you will be violating the terms by not displaying the source licensing that including the name of Wikipedia. The better option will be to look for PD images or CC0 images from Wikipedia that you can use in whatever way you like, but you cannot claim authorship or copyright.

    Thread Starter donnytree

    (@donnytree)

    Thanks for the input Krishna.

    However I would still like to figure out a way to do this if anyone has any advice. Thanks!

    I ran into this problem today..

    I am not using an attachment template and search results are coming up with attachment posts due to matching results in the attachment titles, so I get results that pointlessly takes the user to a page with nothing but the attachment image and the header and footer. To work around this issue, i simply added a line to my loop in search.php:

    <?php while ( have_posts() ) : the_post();
    if (get_post_type($post->ID) == 'attachment' || $post->post_status == 'private'){continue;}?>
    ...
    
    <?php endwhile; ?>

    I also noticed that private pages were also getting returned, so that’s what that post_status condition in my if statement is all about.

    Thread Starter donnytree

    (@donnytree)

    Thanks cornhustlah! Very simple solution, but I am afraid I can’t get it to work for me. I am using the following code:

    query_posts($query_string . '&post_type=post&posts_per_page=-1');
    $results_count = $wp_query->post_count;

    So the count would be off I think if I used your method. I also tried to enter your above code in my while loop, but it didn’t work?

    Thanks!
    Donna

    yea, your count would get messed up, but i think you could keep it in check with every skipped attachment like so:

    if (get_post_type($post->ID) == 'attachment'){
      $results_count--; continue;
    }

    as for it working in general with your loop, i couldnt be sure what might be causing it fail unless i had a look at all of your code.. can you post your full loop here for me to view?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Exclude image titles from search results’ is closed to new replies.