exclude post from RSS feed using custom field
-
Hi folks,
I’m struggling with a piece of code that a helpful guy in the IRC channel gave me that he said “should” work. I appreciate the time he took to put it together but alas it didn’t work as expected.
Here it is:
function my_filter_query($query) { if( !is_feed() ) return; $query->query_vars['meta_key'] = '_rss_include'; $query->query_vars['meta_value'] = '0'; $query->query_vars['meta_compare'] = '!='; } add_action('pre_get_posts','my_filter_query');
The whole idea is that I have a custom post type (I don’t know if this matters) for upcoming gigs (website for a concert venue) but not every gig requires a post page with information on it, just an inclusion in the listings.
From that point I decided I would remove any permalinks to these posts and make sure they don’t appear in the feed so any subscribers don’t end up with links to empty posts containing just a band name.
Can anybody tell me what’s wrong with the code above? I’ve included it in my theme’s functions.php and my theme is a child of TwentyTen.
If somebody can point me in the right direction that’d be magic 😀
Cheers,
Robert
- The topic ‘exclude post from RSS feed using custom field’ is closed to new replies.