Considering that this bit of code lists the 10 most recent posts: <?php get_archives('postbypost', 10); ?> Code (markup): ...how can I change it to display the 10 most recent posts from category ID 4, for example?
<ul> <?php $recent = new WP_Query("cat=4&showposts=10"); while($recent->have_posts()) : $recent->the_post();?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul>
This will show the title with permalink of last 10 posts (of cat 4) as a list but not the post contents..that's ideal for sidebar recent posts....for separate page u can show contents...by adding another line..or 2..
Thanks very much - I appreciate it! If you know of any good sites that explain Wordpress coding, please post it here. I went through the official site, but it only talks about very basic things, and skips over other parts. edit: If you know of a way I can modify search results to display nothing but titles (instead of the entire post), that would be a big help, too
My bad, this is what you want: <?php $recent = new WP_Query("cat=4&showposts=1"); while($recent->have_posts()) : $recent->the_post();?> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <?php the_content(__('Read more'));?><?php endwhile; ?>