Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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.

    #1039620

    Hey 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-search

    Best regards,
    Vinay

    #1039656

    When 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 6 years ago by cg.
    #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.

    #1046357

    Hey!

    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ünter

    #1046401

    Hi,

    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,
    Basilis

    #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 6 years ago by cg.
    #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?

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