Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Show 1 post from 1 category in sidebar WordPress


Hello, I am using this code in my sidebar to show 1 latest post, but I want to only show the latest post from category ID=1.

Can someone edit this code for me to do this?


<?php $archive_query = new WP_Query('showposts=1');
while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>

Answers (1)


John Cotton answers:

$archive_query = new WP_Query('posts_per_page=1&cat=1');