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 βWordPressβs built-in scheduling feature is perfect for staying consistent, but those posts are invisible to your readers until their publication time. Creating a "Coming Soon" or "Upcoming Articles" list can build anticipation and keep your audience engaged. By leveraging `WP_Query` with the `future` post status, you can create a versatile shortcode. This guide shows you how to build a dynamic list of scheduled content that automatically updates as you add new items to your editorial calendar, complete with custom ordering and limit options.
WordPress allows you to schedule posts for future publication. You can showcase these upcoming posts by creating a simple shortcode using WP_Query. This method lets you list future-dated posts dynamically across your site.
How to Create a Shortcode for Future Posts
Use this step-by-step guide to build the shortcode:
Step 1: Write the Function
Add this function to your theme's functions.php file or a site-specific 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'],
);
$query = new WP_Query($args);
ob_start();
if ($query->have_posts()) :
while ($query->have_posts()) :
$query->the_post();
echo '<h4>' . get_the_title() . '</h4>';
echo '<div>' . get_the_content() . '</div>';
endwhile;
wp_reset_postdata();
else :
echo '<p>No upcoming posts found.</p>';
endif;
return ob_get_clean();
}
add_shortcode('upcoming_posts', 'upcoming_posts_shortcode');
Step 2: Insert the Shortcode
You can now use [upcoming_posts] in any post or page. Here's the basic shortcode:
[upcoming_posts]
Customize it with optional attributes:
Sample with Attributes
[upcoming_posts posts_per_page="3" order="ASC" orderby="date"]
Best Practices
Further Reading
This feature is great for promoting scheduled content like announcements, events, or upcoming posts. 
Search our archives or reach out to our team for solutions and expert advice.