GD "Templates" Returned in WP search results

This topic contains 3 replies, has 3 voices, and was last updated by  identity 4 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #526049

    identity
    Lifetime Member
    Post count: 445

    While I love how many of the GD layout templates are now built within standard WP Pages, there is perhaps one drawback, which is that these “pages” may also be returned within standard WP search results…and while I haven’t tested yet, imagine they may also show up in other ways, such as site links via sitemaps, etc.

    Do a search on “GD” or other relevant terms and you’ll see search results including:
    GD Archive Item
    GD Search
    GD Details
    GD Archive
    Location
    Compare Listings

    Is there anyway to make sure that these are excluded from search, sitemaps, direct navigation, etc.?

    Cheers

    #526062

    Alex Rollin
    Moderator
    Post count: 27815

    We have a snippet to exclude listing CPTs from WP Search at the bottom of the page here, but I don’t think it covers the GD templates.

    https://wpgeodirectory.com/docs-v2/faq/common-examples/

    Let me ask the developers to comment on that

    #526545

    Naveen Giri
    Moderator
    Post count: 1559

    Hi identity,

    You can exclude specific pages on site map with following action of Yoast.

    
    add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
      return array( 11, 12); // make sure to replace these numbers with page ids.
    } );
    

    You can use following snippet to exclude specific GD pages on WordPress search.

    
    function wpb_search_filter( $query ) {
        if ( $query->is_search && !is_admin() )
            $exclude_ids  = array( 11, 12); // make sure to replace these numbers with page ids.
            $query->set( 'post__not_in', $exclude_ids );
        return $query;
    }
    add_filter( 'pre_get_posts', 'wpb_search_filter' );
    

    This seems meaningful to me, I will create a improvement request for it. We will make sure to make it more dynamic in future versions.

    Thanks

    #526629

    identity
    Lifetime Member
    Post count: 445

    Excellent! Thanks, I’ll check this out.

    Sadly, this seems like another “basic” thing that should just be built into WP to begin with.

    Cheers

Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket