Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to remove/exclude some posts of a category from RSS feeds after particular date.

First of all i want to specify that same requirement i already accomplish for front page posts. I have two categories x and y and i am showing the posts of these categories on front page. I have created custom field name 'expiration' in which i am giving the date like 2011/08/12 as value which will remove the particular post from front page on given date.

Below is the code to remove particular post where custom field expiration is set.

<?php if (have_posts()) :query_posts($query_string .'&cat=3'); while (have_posts()) : the_post(); 
        $currentdate = date("Ymd");
        $expirationdate = get_post_custom_values('expiration');
        if (is_null($expirationdate)) {
        $expirestring = '30005050'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP;
        } else {

        if (is_array($expirationdate)) {
        $expirestringarray = implode($expirationdate);
        }
        $expirestring = str_replace("/","",$expirestringarray);
        } //else
        if ( $expirestring > $currentdate ) 
        {
         // Enter your post display code after that.?>
            <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="recent_news"><?php the_title(); ?></a><br/>
            <p class="postmetadata"><?php the_time('l, jS F Y'); ?> at <?php the_time('g:i a'); ?></p>

  <?php } endwhile; endif; ?>

In the above code you can see that '&cat=3' is mention which is my category X and similar for Category Y.

Now come to the point how can i set the date once in custom field expiration for front page posts as well as RSS feeds.

i used ( exclude ) tag whose id is ('7') on the posts and filter out but problem is when i put the exclude tag it immediately remove/exclude the post from RSS Feeds. I want to exclude on the basis of expiration date.

Below is the function placed in function.php file which filter out the tag on basis of ID.

<?php function filter_feed_posts($query) {
if($query->is_feed) {

$exclude_tags = array(7);
$query->set('tag__not_in',$exclude_tags);
}
}
add_filter('pre_get_posts','filter_feed_posts');
?>

Please help me to get this done. Your help is appreciated.

share|improve this question

closed as too localized by toscho Feb 18 '13 at 23:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.