Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #900809

    Hi,
    how can I disable images from appearing in the search results? Sometimes image names are not something I want to display so openly. e.g. layer-pexels-photo-268487

    Kind regards
    philipp

    #901888

    Hey philipp,

    Could you please give us a link to your website, we need more context to be able to help you.

    Best regards,
    Victoria

    #902241

    Hi Victoria,
    thanks for replying so quickly.
    I was referring to the site search of the theme: if you put in something like “cloud” in the search form you get results of an actual page AND of an image with cloud in its name. I would like to prevent the latter.

    Thanks
    Philipp

    #903148

    Hi Philipp,

    Here is how to do it:

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #903281

    Hi Victoria,
    thank you, but I have put both snippets (one after the other) in the functions.php of my enfold-child and neither of it works. If I search for “pexels” or “photo” the images still show up in the results. Do you have another idea?

    Thanks
    Philipp

    #904569

    Hi,

    I tried the keyword “cloud” but there are no “image attachment” in the search results. Is this fixed?

    Best regards,
    Ismael

    #904662

    Hi Ismael,
    no, in the meantime I just added a description to that particular image. Try “pexels” as keyword please.

    Kind regards
    philipp

    #905362

    Hi,

    Thank you for the info.

    Please add the following snippet in the functions.php file.

    // exclude images from search results
    add_action( 'init', 'exclude_images_from_search_results' );
    function exclude_images_from_search_results() {
    	global $wp_post_types;
    	$wp_post_types['attachment']->exclude_from_search = true;
    }

    Best regards,
    Ismael

    #905427

    Hi Ismael,
    thanks for the new snippet that I have added to the functions.php file, but still there’s something like “digitale-arch-pexels-photo-21226” in the site’s search results. Am I doing something wrong? My browser cache is deactivated of course.

    Kind regards
    Philipp

    #905432

    Hi Ismael,
    I found the mistake! I accidentally had the “better search” plugin activated without noticing. My bad! Sorry for the awkward confusion. Everything works fine now with the snippet.

    Kind regards
    Philipp

    #905805

    Hi,

    Glad we could help!
    Please take a moment to review our theme and show your support https://themeforest.net/downloads
    To know more about enfold features please check – http://kriesi.at/documentation/enfold/
    Thank you for using Enfold :)

    Best regards,
    Basilis

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.