Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โDisplay scheduled WordPress posts using custom shortcode with WP_Query and post_status set to future. Create shortcode with customizable attributes for posts_per_page to control quantity, order parameter for ASC or DESC sorting, and orderby for sorting criteria. Use ob_start and ob_get_clean for output buffering, implement proper post loop with have_posts and the_post, call wp_reset_postdata after loop, add shortcode with add_shortcode function, and show upcoming blog posts, events, or scheduled content anywhere using simple [upcoming_posts] implementation.
In WordPress, future posts are those scheduled to be published at a later date. To display a list of these posts on your site, you can create a custom shortcode using the WP_Query class. This method allows you to query posts with a future status and output them wherever you need.
Step-by-Step Guide to Display Future Posts
Follow these steps to create a custom shortcode that lists upcoming posts:
Step 1: Create the Shortcode Function
Add the following code to your theme's functions.php file or in a custom plugin:
function upcoming_posts_shortcode($atts) {
$atts = shortcode_atts(array(
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'date',
), $atts);
$args = array(
'post_status' => 'future',
'posts_per_page' => $atts['posts_per_page'],
'order' => $atts['order'],
'orderby' => $atts['orderby'],
);
$future_posts_query = new WP_Query($args);
ob_start();
if ($future_posts_query->have_posts()) :
while ($future_posts_query->have_posts()) :
$future_posts_query->the_post();
// Display your future post content here, e.g., title, content, etc.
echo '<h4>' . get_the_title() . '</h4>';
echo '<div>' . get_the_content() . '</div>';
endwhile;
wp_reset_postdata();
else :
echo '<p>No future posts found.</p>';
endif;
return ob_get_clean();
}
add_shortcode('upcoming_posts', 'upcoming_posts_shortcode');
Step 2: Use the Shortcode
Once you've added the code, you can use the [upcoming_posts] shortcode in your WordPress posts, pages, or widgets to display the list of future posts. Here’s an example:
[upcoming_posts]
This will display all future posts ordered by their scheduled date in ascending order. You can also customize the shortcode by using the following attributes:
-1 to display all upcoming posts. Default is -1.ASC) or descending (DESC) order. Default is ASC.date (scheduled date).Example Usage with Custom Attributes
If you want to display only 5 future posts in descending order, use the following shortcode:
[upcoming_posts posts_per_page="5" order="DESC" orderby="date"]
Place the shortcode inside the content editor of your post or page, and WordPress will output the future posts according to your specifications.
Best Practices for Using Future Post Shortcodes
When using this shortcode on your website, consider these best practices:
Related Resources
For more information, here are some useful external links:
By following this guide, you’ll be able to easily list and display all upcoming posts on your WordPress website, enhancing user engagement and visibility for scheduled content.

Search our archives or reach out to our team for solutions and expert advice.