Excluding Sponsored Posts From Main Page

excluding-sponsored-posts-from-main-page

This is the third installment of my Boring Your Readers With Sponsored Posts series. As the title suggests, by excluding your sponsored posts from your main page, what your visitors can’t see won’t hurt (or in this care, bore) them. However, unlike previous methods when you simply tried to bump down your sponsored posts or exclude them from your feeds, this method might cause you to break the advertiser’s rules. So make sure you double check with your advertisers beforehand.

If you’re read the rules and they don’t require your posts to be on the front page, then congratulations! Now in order to exlude sponsored posts from the main page, you need to place them in a certain category like I mentioned in the post about exluding sponsored posts from your feeds. So pretty much, it comes down to just excluding categories from the main page.

Habitually Good has a nice post about the 2 methods you could use here. The code provided for method 2 is incorrect and produces the white screen of death. :V I’m going to briefly go over the method I use today and provide you with a valid and working code. First, you’ll need to locate The Loop in your index template and insert a function before the code. The Loop generally begins with:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

and ends with:

<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

Now this is the function we’re going to insert before The Loop:

<?php if (is_home()) {
query_posts($query_string . "&cat=-N");
}
?>

The N in the function stands for the category (1, 2, 3, etc) you want to exclude from the main page. Make sure the “-” sign remains intact in the code. In my case, I want to exclude the Basement category, so my code would look like this:

<?php if (is_home()) {
query_posts($query_string . "&cat=-53");
}
?>

Of course, you can add this function to any pages where you wish to exclude the said category; it doesn’t have to be just your main page. ;) That said, you need at least Wordpress 1.5+ in order for the function to work. But God knows why anyone is still using 1.5 or lower when it’s already at 2.6. :wtf:

2 Responses to “Excluding Sponsored Posts From Main Page”

  1. Katy Says:


    Great post! I’ve always been iffy about sponsored posts because I don’t want to bring my blog quality down.Do you know if Payperpost allows this?

    Katys last blog post..Yes, I have a Personal Life 


  2. Mimi Says:


    Elements on a blog page must not obscure any portion of an Opportunity-related post and the posting must be visible, readable and reasonably coherent.
    It looks like PayPerPost might have a problem with this :/ You might want to double-check with them though.


Leave a Reply

Please read the comment policy section of my site policy if this is your first time commenting. Remember, after 10 posts, links become nofollow free. :)


ss_blog_claim=67e17f60ed8c12c9f7739e9bbabbf9d3