How to List Future Upcoming Scheduled Posts in WordPress375

Author: InfoBeep - September 16, 2017 | subject to copyright

What is scheduled or future upcoming posts in WordPress?

WordPress comes with a built-in feature which enables you to schedule your post which means you can publish your post anytime you want in near future without you being present to publish it.

Method 1: Showing Scheduled or Future Posts with plugin

In order to, show you upcoming scheduled post or future posts with plugin, you need to follow the steps below:

  • Install and activate ‘SOUP – Show Off Upcoming Posts’ plugin.
  • After activated, go to Appearance > Widgets.
  • Add ‘Upcoming Posts’ widget to your sidebar. This widget allows you to show number of upcoming scheduled post, dates, link to RSS feed, or link to signup page. Demo picture of widget given below:

upcoming-post

Method 2: Showing scheduled or upcoming posts manually

In order to show scheduled or upcoming posts manually, follow the steps below:

  • Add the code given below in functions.php file or site-specific plugin.
function wpb_upcoming_posts() {

    // The query to fetch future posts

    $the_query = new WP_Query(array(

        'post_status' => 'future',

        'posts_per_page' => 3,

        'orderby' => 'date',

        'order' => 'ASC'

    ));

// The loop to display posts

if ( $the_query->have_posts() ) {

    echo '<ul>';

    while ( $the_query->have_posts() ) {

        $the_query->the_post();

        $output .= '<li>' . get_the_title() .' ('.  get_the_time('d-M-Y') . ')</li>';

    }

    echo '</ul>';

} else {

    // Show this when no future posts are found

    $output .= '
No posts planned yet.
';

}

// Reset post data

wp_reset_postdata();

// Return output

return $output;

}

// Add shortcode

add_shortcode('upcoming_posts', 'wpb_upcoming_posts');

// Enable shortcode execution inside text widgets

add_filter('widget_text', 'do_shortcode');
  • Go to: Appearance > Widgets.
  • Add a text widget to your sidebar and add shortcode inside the widget [upcoming_posts} as shown in the figure below:

recent-commernts

  • Click save