excluding-sponsored-posts-from-main-page

07/18/2008

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:

Filed under: Blogging, Tutorials

2 Comments

2 Comments

  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

subscribe to Super Girl

Konnichiwa

Enjoyed the post? Why not subscribe today?
rss feed Subscribe via RSS
rss feed Subscribe via Email
Follow Super Girl Subscribe via Bloglovin

Or bookmark it and share it with your friends:
Share/Save/Bookmark

Featured

Cirtex Hosting
Your ad here

omg, last night was ridiculous....ly fun :D follow me on twitter @origamee