-
AuthorPosts
-
January 22, 2018 at 2:09 pm #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-268487Kind regards
philippJanuary 24, 2018 at 5:10 am #901888Hey philipp,
Could you please give us a link to your website, we need more context to be able to help you.
Best regards,
VictoriaJanuary 24, 2018 at 5:45 pm #902241Hi 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
PhilippJanuary 26, 2018 at 4:46 am #903148Hi Philipp,
Here is how to do it:
If you need further assistance please let us know.
Best regards,
VictoriaJanuary 26, 2018 at 10:37 am #903281Hi 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
PhilippJanuary 30, 2018 at 2:24 am #904569Hi,
I tried the keyword “cloud” but there are no “image attachment” in the search results. Is this fixed?
Best regards,
IsmaelJanuary 30, 2018 at 8:24 am #904662Hi Ismael,
no, in the meantime I just added a description to that particular image. Try “pexels” as keyword please.Kind regards
philippJanuary 31, 2018 at 5:49 am #905362Hi,
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,
IsmaelJanuary 31, 2018 at 9:13 am #905427Hi 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
PhilippJanuary 31, 2018 at 9:28 am #905432Hi 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
PhilippJanuary 31, 2018 at 8:57 pm #905805Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.