I found the following code on the forums:
<?php $posts = get_posts( "category=10" ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endforeach; ?> <?php endif; ?>
The goal is for it to list the latest 5 post titles on the category page that it is in.
The way it is currently written, the category ID is hard coded in, how can I make it dynamic based on which category it loads?
Thanks for any help anybody can provide
- The topic ‘List Posts in Category’ is closed to new replies.