Show a list of scheduled posts

When writing an article, you will probably want to publish it right away. But sometimes you will need to schedule a post and set a date and/or time when it will go live. It might be a special interview you have prepared or a review which shouldn’t be published before a certain date. No matter the reason, we all need to schedule posts from time to time and WordPress already has the feature embedded into the post editor.

While there are times when you don’t want your readers to know what is coming up, there are definitely situations when you could use a list of upcoming articles.
Wouldn’t it be nice if you create a list of your scheduled posts and show them to the public? By creating that list, you are actually creating a teaser which may “force” your visitors into stopping by tomorrow just because they’re interested in your upcoming interview or a review.

OK, we’ll stop blabbing because you probably know your reasons behind displaying a list of future posts, so here’s how to create one without using a plugin. If you are interested in using plugins for the job, take a look at these plugins which can show upcoming posts.

Show a list of scheduled posts:

  1. Open sidebar, header, footer or a file wherever you would like to display a list
  2. Copy and paste this code:
  3. <div id="scheduled_posts"> <div id="scheduled_posts_header">
    <p>Prepare for:</p></div>
    <?php query_posts('showposts=5 & post_status=future'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div > <p class><b><?php the_title(); ?></b>
    <?php edit_post_link('edit',' (',')'); ?><br />
    <span><?php the_time('j. F Y'); ?></span></p>
    </div> <?php endwhile; else: ?><p>There are no upcoming posts.</p>
    <?php endif; ?> </div>
  4. Change list title on line #2
  5. Change number of displayed posts on line #3
  6. Change message if there are no scheduled posts on line #8
  7. Save changes

The code above will take 5 of your latest posts which have a ‘future’ status and display them in a list. You can change the number of posts which you want to display on the third line while you can easily modify the text between <p></p> tags and change the look of a list.

If you don’t have any scheduled posts, a function will return text found on the 8th line.

What’s great about this code is that it will add a link for admins which will lead them to post edit page, while all the others will only see a list of scheduled posts with a date next to it.
Now the code is ready and after you customize it a bit, you can style the list so you can fit it on your page. You can do that by styling the scheduled_posts DIV – here’s a simple example which will print the list in red (you should write the CSS code in your styles.css file):

#scheduled_posts {
color: red;
}

Go ahead, play around with some different styles or apply one already created by theme and enjoy your new list of scheduled posts.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *