excluding-posts-from-index

Excluding posts from index

written on Friday, July 18, 2008
filed under Blogging, Tutorials

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.

*****Don’t use this method with PayPerPost because one, it breaks their rules, and two, their advertisers will start whining and crying because you’re “cheating” them. That I find rather rich since they’re cheating the Google PR system themselves. It’s not my fault your fucking site blows and you need to resort to this MOST PITIFUL way of marketing. Other advertisers are MUCH more lenient, thank God.******

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 exclude 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.

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 STFU 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.

4 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.

  3. Jenny says:

    using this method… does it screw up your post count? Like… if I put that in, and I have 3 posts on the front page and wanna exclude one of those posts, would only 2 posts show up or would it just get rid of the one i exclude and go on its every day thinger?

    • Jenny says:

      Nevermind I just answered my own question. LMAO Yay for test themes.

Leave a reply

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

Related Posts

I hate how I go MIA once school starts. This is bad -_-
twitter