Content Marketing

WordPress: Publish Future Posts as Upcoming Events

We built a WordPress micro-site for Corporate Blogging for Dummies and wanted to have a section where we displayed upcoming events in the lower sidebar. The solution to do this is actually quite simple and built directly into WordPress. Within your theme, you can add a loop that only queries and displays future posts for a specific category that is only used for Future Events:

<?php query_posts('order=ASC&cat=3&post_status=future,publish'); 
if(have_posts()) : 
while(have_posts()) : the_post();
if(strtotime(get_the_time("F jS Y")) > time()) :
else: echo $post->id; ?>
<li><p class="right">
<?php echo get_post_meta(get_the_ID(), 'location', true); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a>
<p class="left"><strong>
<?php the_time("M"); ?></strong>
<?php the_time("d"); ?>
<div class="clear">
<?php endif; 
echo "Check back soon!"; 
endif; ?>

The query_posts method is placed just before the WordPress loop to limit the posts published to the query used. Since these are future scheduled blog posts (on the event date), you don’t have to worry about them being displayed on your core blog in your template. You may want to hide the categories from your category list, though. This can be accomplished by editing your category list in your WordPress template using the exclude option:

<ul><?php wp_list_categories('orderby=name&exclude=3'); ?></ul>

We also added metadata for the post to display a location for the event. This is accomplished using WordPress’ Custom Fields section. Simply type in location for the field name and your location for the value… then retrieve the location for display using the get_post_meta command above.

The resulting site is pretty cool, with a very unique design and layout that has all the elements necessary to promote the book:
Corporate Blogging Tips.png

Douglas Karr

Douglas Karr is the founder of the Martech Zone and a recognized expert on digital transformation. Douglas has helped start several successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to launch his own platforms and services. He's a co-founder of Highbridge, a digital transformation consulting firm. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles


  1. We also built a custom feed with the future events posted and modified the XML sitemap generation to publish future posts. If you’re using Arne Brachenwald’s XML Sitemap Generator, line 1747 of sitemap-core.php can be updated to <code>$where.=” (post_status IN (‘publish’,’future’) AND (post_type = ‘post’ OR post_type = ”)) “;</code>

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.