Support » Themes and Templates » How do I display posts from a specific category on a page?

  • shoesandsocks



    I was wondering if someone could help me out with something on a website I am trying to build – – I have a fairly rubbish understanding of php so am struggling a bit…!

    I have a page called ‘news’ and a page called ‘articles’ (each using their own template).

    Currently both pages pull through all posts. What I would like is for the news page to pull through only posts in the ‘news’ category and the ‘articles’ page to only pull through posts in the ‘articles’ category.

    What do I need to add to the page templates to make this happen?


    Lisa 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • ajennell


    I know the fallowing code will call up the recent entries for a specific post. Just change CATEGORYNAME to the name of the category. Then enter how many posts you would like shown. I’m sure this isn’t what you want, but I hope it helps.

    <?php query_posts('category_name=CATEGORYNAME&showposts=5');
    while (have_posts()) : the_post();
      // do whatever you want
    <b><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>


    Thanks, that was really helpful! 🙂

    I’ve now got the News items pulling through on the News page and the Articles on the Articles page.

    Moderator Samuel Wood (Otto)


    Or you could simply use Category Templates in the first place, like the system was designed to do.



    Thanks, I will have a read, it looks very useful!

    …Not sure how I managed to miss that in my searching…


    This code worked great for me – I wanted to put a list of the latest news from a specific category on my front page.

    Does anyone know how I include 2 or 3 categories, I imagine I have to change something here:

    <?php query_posts(‘category_name=CATEGORYNAME&showposts=5’);


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I display posts from a specific category on a page?’ is closed to new replies.