WordPress.org

Support

Support » How-To and Troubleshooting » “In The Pipeline”/”Upcoming Posts”

“In The Pipeline”/”Upcoming Posts”

  • Just curious…is it possible to have a sidebar item that can show upcoming posts ( Posts that have been written, but not yet published? ( IE: The one that you wrote earlier, and set to publish at a certain date.) )

    If so, how can I do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try something like this:

    function upcoming_posts() {
    	global $wpdb;
    
    	$sql = "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status = 'draft' ORDER BY 'ID' DESC";
    	$results = $wpdb->get_results($sql);
    
    	if ($results) {
    		echo '<ul>';
    		foreach ($results as $post): ?>
    
    			<li><a href="<?php echo get_permalink($post->ID); ?>"><?php get_the_title($post->ID); ?></a></li>
    
    		<?php endforeach;
    		echo '</ul>';
    	}
    }

    Just copy that into your functions.php file and call it in your sidebar with:
    <?php upcoming_posts(); ?>

    Just threw it together, but it should work fine. It just makes a list of the post’s permalinks, but it can be expanded to fit your needs. Let me know…

    Thanks. I’ll try it out as soon as I get a chance 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“In The Pipeline”/”Upcoming Posts”’ is closed to new replies.
Skip to toolbar