Post Pic

How to: List future posts

Do you ever wished to be able to use WordPress to list future events? This can be very useful for exemple if you’re using WordPress for a band website and like to list your future shows.

To achieve this recipe, simply paste this code where you'd like you future posts to be displayed:

<div id="zukunft">
	<div id="zukunft_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>

Related Posts

Related Posts

No related posts.

2 Responses

Jul 26 2011 13:04

I am struggling to get this paginating, using a custom post type.

Dec 31 2012 05:57

I made a couple of tweaks to this code that make it more user friendly for my site. I stripped out line 2 and used the Text Widget title to write “Upcoming posts”. I then added quotes around the post title display, added the word “on” between the title and date, and switched the date to a US-style date display.

” on

No future events scheduled.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox