kjo1969
Member
Posted 8 months ago #
Can anyone walk me through how to set up a widget so that it only pulls in ONE category of posts?
Right now, all I have is the Recent Posts, and have copied that PHP to the homepage, where I'd like to feature one category of Posts - "What's New" - but not all of them. Any help would be greatly appreciated! Thanks!
Consider downloading and installing Otto's PHP Code Widget.
Then put this in one of those widgets:
<?php
//get 7 posts for category id 7
$posts=get_posts('cat=7&showposts=5');
if ($posts) {
foreach($posts as $post) {
setup_postdata($post);
?>
<?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php }
}
?>
Please remember to support our plugin authors by clicking on the Donate button there.