Support » Themes and Templates » Display posts from a specific category

  • Resolved Zane


    Hi there,

    I recently discovered code (from Sitepoints Wicked WordPress Themes) that allows for the latest 4 posts to be displayed on a page. The code sits in the functions file and is then called within the page.

    function wicked_indexloop() {
      if (have_posts()) : while (have_posts()) : the_post(); ?>
        ⋮ we'll do some stuff here
      <?php endwhile; else: ?>
        ⋮ if there are no posts, we'll display an error
      <?php endif;

    How can I modify this to display the 4 latest posts from a specific category?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Use something like: query_posts(‘cat=3&posts_per_page=4’)

    That should return last four posts from category 3.

    This works for me, where ‘Gallery’ is the name of the category I’m looking to display –
    : query_posts( ‘Gallery’ );

    Great, thanks! I will give them both a try and see what happens;)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display posts from a specific category’ is closed to new replies.