There are several solutions presented in the Codex. See
http://codex.wordpress.org/The_Loop
(especially Multiple Loops examples)
http://codex.wordpress.org/The_Loop_in_Action
http://codex.wordpress.org/Template_Tags/query_posts
[for the moment it is down but hopefully it will be back soon]
Thread Starter
Edd
(@edd)
Thanks for those links, I am still having a bit of trouble though. I’ve figured I need to use something like:
<?php
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
get_sidebar();
get_footer();
?>
And I found I need to include query_posts("cat=2"); as well. The above code generates posts from all categories, and when I try adding the query posts line I just get a 404 error. Where should I be putting that line?
Many thanks,
If you take a closer look to the Multiple Loops examples and also the query_posts examples – it is always before the Loop.
Thread Starter
Edd
(@edd)
I had another look and I got:
<?php $my_query = new WP_Query('category_name=Site-news&showposts=10'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<!-- Do special_cat stuff... -->
<?php endwhile; ?>
I do this and nothing happens, it seemingly just ignores the code. What have a I done wrong? Also, the category is called “Site news” – how should I express that space? I have tried underscores, hypens, %20 but none made a difference to a bit of clarifcation on that would help too.
Thanks for the help so far 🙂
Insert the category name as it is
WP_Query('category_name=Site news&showposts=10')
<!-- Do special_cat stuff... -->
Did you replace this with the template tags you want to use there? E.g. the_title, the_content etc. see how it is done in your “normal” Loop 🙂
Thread Starter
Edd
(@edd)
Thanks SO much for the help, I have got it working now! It was what you suggested, I didn’t realise!
Thanks again!