Certain Page to show Posts from certain category

Discussion in 'WordPress' started by MakeThatDollar, Jun 5, 2008.

  1. #1
    How can I have a certain page show only posts from a specific category?
     
    MakeThatDollar, Jun 5, 2008 IP
  2. hmansfield

    hmansfield Guest

    Messages:
    7,904
    Likes Received:
    298
    Best Answers:
    0
    Trophy Points:
    280
    #2
    If you use a category cloud, that would do the trick, or just put the category widget that comes already with 2.5, and put it in your sidebar. When people click the category (drop down menu) , they will only get posts in that category.

    Also, most premium themes (paid) have the categories listed across the top of the page, and when clicked show all posts in that category.
     
    hmansfield, Jun 6, 2008 IP
  3. mizaks

    mizaks Well-Known Member

    Messages:
    2,066
    Likes Received:
    126
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Assuming you are using WordPress, put this in your page:

    
    <ul>
    <?php $posts = get_posts('numberposts=XXX&order=ASC&orderby=post_title&category=YYY'); ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <li><a href="<?php the_permalink() ?>" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    
    Code (markup):
    Replace the XXX with the number of posts you want listed and the YYY with the ID of the category you want posts from.
     
    mizaks, Jun 6, 2008 IP