Title: A function to remove posts from rss feed?
Last modified: August 30, 2016

---

# A function to remove posts from rss feed?

 *  [trouille2](https://wordpress.org/support/users/trouille2/)
 * (@trouille2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/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.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [rss-feed](https://wordpress.org/support/topic-tag/rss-feed/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [trouille2](https://wordpress.org/support/users/trouille2/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/a-function-to-remove-posts-from-rss-feed/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
