List Your Upcoming Posts


A sure way to bring readers back to your blog is to tell them what is coming up for release. This is an especially useful feature if you use the post scheduling feature in WordPress. While there are probably plugins that will do this for you, all you actually need is this code snippet. You can just copy and paste it into one of your theme files where you want the list to appear - e.g. the sidebar.

WARNING: Do not do this if you are not comfortable altering the files in your theme. Make sure you make a back up of the file that you are going to change before making the change.

<div id=“crystal_ball”>
<div id=“crystal_ball_header”><p>Future events</p></div>
<?php query_posts(’showposts=10&post_status=future’); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div >
<p class><b><?php the_title(); ?></b><?php edit_post_link(‘e’,‘ (’,‘)’); ?><br />
<span class=“datetime”><?php the_time(‘j. F Y’); ?></span></p>
</div>
<?php endwhile; else: ?><p>No future events scheduled.</p><?php endif; ?>
</div>

This willl produce a list of posts that are marked Future. If you want to show less or more than 10 upcoming posts just change the number in the line “ <?php query_posts(’showposts=10&post_status=future’); ?> ” to the number of posts you want to display.

Its as easy as that.

Reblog this post [with Zemanta]

, ,