Support » Fixing WordPress » A function to remove posts from rss feed?

  • Hello,
    A few years ago, I customized the rss feed to select which post should be in it or not.
    I first added a custom checkbox field to the post, telling if the post was ok to be in the feed or not.
    Then I simply put an IF condition in the feed-rss2.php file. If the custom field was true, the post was included otherwise it was skipped.

    I say “was” because now, I forgot it and updated wordpress without keeping this old file… My mistake…
    So now, I would like to do almost the same but via the functions.php.
    Does anyone can help me to create a function that will sort the posts following the value (true/false) of a custom field? How can I control the feed itself? I would like to be able to rewrite the “while” part of feed-rss2.php to have something like :

    while( have_posts()) : the_post();
    	if(get_post_meta(get_the_ID(), 'my-custom-field-visibility', true)){
    	?>
    	<item>
    		<title><?php the_title_rss() ?></title>
                   .....

  • The topic ‘A function to remove posts from rss feed?’ is closed to new replies.