How to remove a Post from the RSS Feed

For whatever reason you may need to Publish a WordPress Post without having that Post show in the Feed. The Post will still show on your Website however feed subscribers won’t see the Post (and any services such as Mailchimp or Aweber that use your Feed won’t ‘see’ the Blog Post).

Just add the code below to your functions.php and replace 2151, 2217, 2401 with your Post numbers/IDs:

function ge_post_exclude($where, $wp_query = NULL) {
	global $wpdb;
	if ( !$wp_query )
		global $wp_query;
	if ($wp_query->is_feed) {
		$where .= " AND $wpdb->posts.ID NOT IN (2152, 2217, 2401)";
	}
	return $where;
	}
add_filter( 'posts_where','ge_post_exclude', 1, 2 );

Please note that I’ve been using this code for awhile and attained it from somewhere but I just can’t recall where.

Comments

Australian WordPress Specialist

Australian WordPress Specialists.

OrganicWeb provides leading WordPress solutions. Specialities include developing high converting Websites built with SEO from the ground up. Contact us to get more customers from your Website.

Leave a Reply