One post & omit category (s) in WordPress

One post & omit category (s) in WordPress

There are a number of different way to do this. I’m sure there are plenty of folks more versed in PHP programming than I out there that could give you seven ways from Sunday  to accomplish this. I’m a designer, not a programmer.  Here’s my WordPress solution.

I wanted my latest blog post to show up on my home page. That’s simple. Slap the following function in your home.php file just before your loop and that’s it. Hello blog. Hello ONE post.

[php]<?php query_posts(‘showposts=1’); ?>[/php]

Pretty straight forward there. So all was fine until I published a post about a custom bicycle I am having made by  an individual up in Asheville, NC. I’m totally cool with it appearing on my site, just don’t want it popping up on the front page. It’s just not really content relevant in terms of jiving with the rest of the site. So from this point forward, I wanted any post in my WordPress “personal” category NOT to show up my home page.

[php]<?php query_posts(‘showposts=1’); ?>[/php]

And replaced it with:

[php] <?php query_posts(‘showposts=1&cat=-17’); ?> [/php]

In English, the above PHP code snippet would say: “Go back to your database, look for the posts, find the most recent post and ignore any posts that have “personal” category ID”.  If you read this and said “what’s the frig is category ID?”, you’re going to want to take a step back and zip on over to google. Very easy to to figure that one out.