Support » Themes and Templates » Posts list by category

Viewing 1 replies (of 1 total)
  • Use this:


    <ul>
    <?php
    $posts = get_posts('numberposts=5&category=1');
    foreach($posts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

    You can specify the number of posts you want to get and from which category ID. Make sure that you don’t query more posts than are actually in the category because you’ll get an error message. There are also other filters for get_posts(). You can read more about it here:

    http://codex.wordpress.org/Template_Tags/get_posts

Viewing 1 replies (of 1 total)
  • The topic ‘Posts list by category’ is closed to new replies.