Tagged: Custom Footer, search results
-
AuthorPosts
-
November 30, 2018 at 12:48 pm #1039282
Hi,
I created a custom footer.
When I use the Search the footer page shows in the Results. How can I stop this custom footer page (which is not like any other normal front facing page) showing in the search results?
Thanks.
December 1, 2018 at 11:37 am #1039620Hey Heathcliffe,
There are multiple ways you can achieve this please refer to the below links
https://www.wpbeginner.com/wp-tutorials/how-to-hide-a-wordpress-page-from-google/
https://wordpress.stackexchange.com/questions/5453/how-do-i-remove-pages-from-searchBest regards,
VinayDecember 1, 2018 at 3:56 pm #1039656When you edit that page (WP admin) you can see its ID in the address bar of your browser.
Note that and use the following code in your functions.php to exclude it from the search.
Switch “0815” to you footer page id. Use comma separation to exclude multiple page ids from search.
As always it’s recommended to use a child theme for modifications to the functions.php./** * Exclude page ids from search results */ function cg_mod_search_filter( $query ) { if ( $query->is_search && $query->is_main_query() ) { $query->set( 'post__not_in', array( 0815 ) ); } } add_action( 'pre_get_posts', 'cg_mod_search_filter' );
- This reply was modified 5 years, 11 months ago by cg.
December 8, 2018 at 12:05 am #1042253@Vinay. Can you guys accept this is a bug and will be fixed in a new release?
This is not about hiding a page from Google.
ENFOLD knows the page ID. It is clearly defined in the Enfold theme settings.
A user should not have to start hacking code when the expected functionality of a feature is NOT to appear in search results. It is common sense surely.
Thanks @cg I will give this a go.December 17, 2018 at 4:13 pm #1046357Hey!
Thank you for reporting this.
We really missed that. I will add a fix to core – but I’m not sure if it will be in the next release.
Cheers!
GünterDecember 17, 2018 at 5:59 pm #1046401Hi,
Tank you for the feedback.
The issue will be fixed on the next upgrade – we have our developers working on it.
It will be the same thing as we suggested BTW – a noindex value to the virtual paged generated.Best regards,
BasilisDecember 17, 2018 at 6:04 pm #1046403@Basilis: a html-header-meta “noindex” won’t be enough to exclude those pages from the WP internal search and ajax suggest, i am afraid.
Edit: the link from Vinay about “how to hide a wordpress page from google” wasn’t even “on topic” …
Edit: My reply isn’t meant as an “accusation” … i just feel like you are “on the wrong track” … :-)
- This reply was modified 5 years, 11 months ago by cg.
December 17, 2018 at 6:41 pm #1046422@Günter – thanks, I hope you understand the problem, as it seems not everyone does.
I simply want to search the site using the inbuilt search function that you add to the header.
I do not expect the footer page (nor any other template page) to appear in the search results.
Can you ensure the fix is detailed in the Changelog in the release it is fixed in, please, as I have simply opted not to use the search for now?
-
AuthorPosts
- You must be logged in to reply to this topic.