Showing posts from the right category?
I’ve got a small problem.
When I click on a link from a certain category I want to display a list of the posts in that category. Sounds simple but I can’t get it to work.
I’m running the_Loop twice on this page so I have to use my own query to get the posts – problem is that I don’t know how to get it to show the posts from the right category. I’m only using 5 categories so it’s always cat ID 1, 2, 3, 4 or 5 that needs to go where it says “cat=1” now. How can I do this? I would settle for a straight up php-solution if there is no good way to do it with template tags.
Here’s the code i’m using:
<?php $my_query = new WP_Query('cat=1&showposts=30'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php echo get_permalink() ?>"><?php echo $post->post_title; ?></a></li>
<?php endwhile; ?>
- The topic ‘Showing posts from the right category?’ is closed to new replies.