Hi guys!
Today’s little post is a little quick tip on how to bring in all the posts from a specific category into your web design.
Those of you that currently use the WordPress loop to bring in your latest blog / news items to your website will know that it’s all good but what if you wanted 2 feeds on your site, each for a specific category, or just wanted 1 feed but not all your posts, well here is your solution.
The code:
<ul>
<?php require($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-load.php'); query_posts('cat=3&showposts='.get_option('posts_per_page')); if (have_posts()) : while (have_posts()) : the_post(); ?>
<li> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a> </li>
<?php endwhile; else: echo "no posts"; endif; ?>
<?php wp_reset_query(); ?>
</ul>
This code will show your latest news items from your category with the ID of 3 and display them in a unordered list. All you will need to do is change the ID for the ID of your desired category and you’re done!
But Gav..how do I find my category id?
Let me show you:
In your wordpress back end, click on categories and on the right hand side it will show you your whole list of categories. To find out your ID, just hover over the category name and look at the bottom left of your browser. Your browser should display the link that category links to, near the end it will say ID and a number after it, thats your ID!
You will now be able to bring in your chosen category into your web design, and display as many different categories as you link, just remember to change the ID!
Thanks for reading guys, hope you found this beneficial. Next week I’ll be getting back onto more CSS3 goodies!
Have a GREAT weekend!

