• Resolved Zane

    (@xane_777)


    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() {
      query_posts("posts_per_page=4");
      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;
      wp_reset_query();
    }

    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’ );

    Thread Starter Zane

    (@xane_777)

    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.