-
AuthorPosts
-
November 2, 2018 at 10:15 am #1029092
Hi!
I’m building a website where small parts of texts plus an image are created as portfolio items, and used in a page in a portfolio grid. When I’m performing a search on the site, all the individual portfolio items are also visible and I would like to hide those. I’ve placed some links in the private section.
I’ve tried using https://kriesi.at/support/topic/remove-portfolio-category-from-search-results/ but that did not do the trick. I have changed the name of the Portfolio items base, but using the new name instead of ‘portfolio’ did not help: http://up.strila.nl/b7b634
Can you help me in hiding the portfolio items from showing up in the search results?
Thanks!
DanielNovember 5, 2018 at 3:23 pm #1029926Hey Daniel,
Have you tried this code?
If you need further assistance please let us know.
Best regards,
Victoria- This reply was modified 6 years, 1 month ago by Victoria.
November 5, 2018 at 3:36 pm #1029933Hi Victoria,
That is indeed the exact same URL as I’ve posted in the first post. So yes, I need further assistance :)
Regards,
DanielNovember 9, 2018 at 3:47 am #1031489Hi,
Thank you for the update.
The following snippet should help. Just add it in the functions.php file:
// exclude images from search results add_action( 'init', 'exclude_portfolio_from_search_results' ); function exclude_portfolio_from_search_results() { global $wp_post_types; $wp_post_types['portfolio']->exclude_from_search = true; }
Best regards,
IsmaelDecember 5, 2018 at 5:24 pm #1041301Hi Ismael,
I’ve tried the code above, but still seeing portfolio items in the search results. See the link in the private section.
Hope you can help!
December 6, 2018 at 12:09 pm #1041597Hi,
Which ones of those items are portfolio? I can only see pages when I use the “marrakech” keyword.
Best regards,
IsmaelDecember 6, 2018 at 1:38 pm #1041644Hi Ismael,
I’ve posted another, more clear, search result, where the results 1,2,3,5,6,7 and 8 link to portfolio pages.
edit: I did change the settings for Portfolio items in /wp-admin/options-permalink.php, I don’t know if that makes a difference?
- This reply was modified 6 years ago by Daniel.
December 7, 2018 at 10:49 am #1041975Hi,
Thanks for the update. Try this filter instead:
add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod'); function avf_portfolio_cpt_args_mod($args) { $args['exclude_from_search'] = true; return $args; }
Best regards,
IsmaelDecember 7, 2018 at 12:48 pm #1042017This works, thanks Ismael!
December 8, 2018 at 6:16 am #1042342Hi,
Great, glad you got it working. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardDecember 9, 2018 at 6:29 pm #1042783You can close the topic, thanks!
December 10, 2018 at 5:48 am #1042906Hi,
Awesome! Glad we could help!
Please take a moment to review our theme and show your support https://themeforest.net/downloads
Don’t forget to bookmark Enfold Documentation for future reference.Thank you for using Enfold :)
Best regards,
Ismael -
AuthorPosts
- The topic ‘Hide all portfolio items from internal search results’ is closed to new replies.