In WordPress, scheduled posts—also called future posts—are those set to publish on a future date. You can display these posts on your site using a custom shortcode with the WP_Query
class. This lets you fetch and output future posts anywhere you need.
Step-by-Step: Display Scheduled Posts via Shortcode
Here’s how you can create a shortcode to show upcoming posts:
Step 1: Build the Shortcode Function
Add the code below into your theme’s functions.php
file or 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 = new WP_Query($args); ob_start(); if ($future_posts->have_posts()) : while ($future_posts->have_posts()) : $future_posts->the_post(); echo '<h4>' . get_the_title() . '</h4>'; echo '<div>' . get_the_content() . '</div>'; endwhile; wp_reset_postdata(); else : echo '<p>No future posts available.</p>'; endif; return ob_get_clean(); } add_shortcode('upcoming_posts', 'upcoming_posts_shortcode');
Step 2: Implement the Shortcode
Use the shortcode [upcoming_posts]
within any post, page, or widget to display future posts. Example:
[upcoming_posts]
You can also customize it using parameters:
- posts_per_page: Number of posts to show (default: -1).
- order: Sorting order,
ASC
orDESC
(default: ASC). - orderby: Field to sort by (default: date).
Example: Display Limited Posts in Descending Order
[upcoming_posts posts_per_page="5" order="DESC" orderby="date"]
Pro Tips
- Use CSS to match your theme design.
- Enable caching for better performance with multiple future posts.
- Limit post count for better readability.
Helpful Links
This method helps highlight upcoming content and improves user engagement by letting visitors know what’s ahead.