Pull Only Published Recent Posts in Sidebar
-
I am hardcoding part of my sidebar and have added code to pull the most recent posts, but it is pulling drafts as well as published posts. How can I pull only published posts? Also, how can I limit the number of posts pulled?
Here’s the code I have:
<!--Recent Posts--> <h2<?php _e('Recent Posts'); ?></h2> <ul> <?php $recent_posts = wp_get_recent_posts(); foreach( $recent_posts as $recent ){ echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.$recent["post_title"].'" >' . $recent["post_title"]. '</a> </li> '; } ?> </ul>
I’m running multisite with buddypress.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Pull Only Published Recent Posts in Sidebar’ is closed to new replies.