How to exclude GeoDirectory listings from RSS feed?

This topic contains 3 replies, has 2 voices, and was last updated by  Simone 10 years, 5 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #15963

    Tom
    Buyer
    Post count: 123

    Dear support team,
    I have a website, and as part of the website, I am currently building a directory. Currently, every directory listing that is added is also sent out via RSS – which is something I do not want. I do only my content-rich articles to be spread via RSS, not every little directory entry.

    I found the following code in the internet, which refers to post categories. Is there a way to alter this code (or is there maybe a function in GD) so that the GeoDirectory post types (for exmple gd_place) are not sent out via RSS?

    Thanks a lot,
    Tom

    ((Here’s the code I found:))

    
    
    function myFeedExcluder($query) {
     if ($query->is_feed) {
       $query->set('cat','-12');
     }
    return $query;
    }
    
    add_filter('pre_get_posts','myFeedExcluder');
    #15972

    Simone
    Expired Member
    Post count: 3515

    Hi Tom, you could do something like this:

    
    
    
    function myFeedExcluder($query) {
     if ($query->is_feed) {
      $query = new WP_Query( array( 'post_type' => array( 'post', 'page' ) ) );
     }
    return $query;
    }
    
    add_filter('pre_get_posts','myFeedExcluder');

    in this case, $query will have only posts and pages.
    Not tested thou, should be working

    #16776

    Tom
    Buyer
    Post count: 123

    Yep, seems to work – thank you!
    Cheers,
    Tom

    #16793

    Simone
    Expired Member
    Post count: 3515

    Awesome!

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
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount