Create Post Only for your RSS Subscribers

Post Only for your RSS Subscribers

If you would like to give an exclusive offer to your regular RSS subscribers, here’s a nice trick to create a post that is only visible to your RSS subscribers.
First of all, create a category that will hold posts to show to your RSS suscribers. For example, create a category ‘RSS’ and add some posts exclusively to it. Note down the category ID of this category. Now in your theme’s functions.php file, add these lines of code so that it is only shown to RSS subscribers.

<?php
function excludeCategory($query)
{
if($query->is_home | $query->is_archive )
//Exclude category from all other pages except RSS
$query->set('cat','-3');
return $query;
}
add_filter('pre_get_posts', 'excludeCategory');
?>

Source

Tags:  RSS, Subscribers, WordPress subscriber, WordPress, WordPress post, functions.php, exclude Category, exclusive offer, Regular Rss.


About Admin

Hi I am Md. Masum Billah Contributor of this website. I always like to share various things with other. In this website I am sharing web design related tips and tricks, necessary web development tools, source codes for beginner and advance web developer. You may join with us to help other who want to learn web design and development. Thank you for stay with.

Leave a Reply

Your email address will not be published. Required fields are marked *