Wouldn’t it be a cool idea to let your readers or fan base preview what articles are scheduled to publish at a later date? It would inform them of great things to come and could even encourage them to return consistently to check out what’s coming next. A preview page like the one mentioned above would certainly work best on a site or blog that features numerous writers and editors, such as this one.
The code to implement such a feature is quite simple, but first users must create a (new) unique WordPress page related to “post previews” or “upcoming articles”. More specifically this newly created page will display the preview listing we want our community and readers to see.
The following code can be placed anywhere on a WordPress blog or site provided it doesn’t interrupt or break up an existing command code. The idea is to place the segment where you would like the listing to appear, as we have already created a new WordPress page that would be the ideal place to input the code. However if you would like to customize where the code is displayed or perhaps even display it in another location on your site (main page etc.) there are no additional steps required.
<?php query_posts(‘showposts=7&post_status=future’); ?> <?php if (have_posts()) : ?> <h3>Coming Soon!</h3> <ul> <?php while (have_posts()) : the_post(); ?> <li><?php the_title(); ?> — <?php the_time(‘l, F j, Y’); ?></li> <?php endwhile; ?> </ul> <?php else: ?> <p>No future publications pending!</p> <?php endif; ?>
(If you would like to customize what displays when there are no new posts set to publish simply alter the following line of code by replacing it; “No future publications pending!”)
Once the code has been added to your site you can save the source file you edited in the process (header.php etc.). When that is complete you are all done!
To provide a more in depth description of what the above code does you simply have to understand how WordPress labels posts. The code above will query the post status for all site posts and display any with the “pending publication” status, which means any post that has been scheduled for publication at a later date. Subsequently this means as an admin if you would like your future posts to display using the code above then you will need to make sure they are listed under a “scheduled publish” status. Any posts listed as “Submit for review” or “Draft” will not appear in the listing related to the above code. Keep that in mind when implementing this feature into your WordPress blog or site.
Now that you’ve successfully added the related code segment go check out your cool new “upcoming posts” feature! Neato!