Performancing Metrics

WordPress Plugin: View Future Posts

For a non-blogging project I’m working on I integrated WordPress into the website to use some of the functionality such as recent news and future dated events. I needed to display a list of future dated events with linked titles and the time left to the event in a sidebar. Similar to what you currently see in the WordPress Dashbord. I needed the post to display if the title permalink was clicked, but I didn’t want the post to display anywhere else such as categories or recent posts. WordPress by default does not allow the viewing of future dated posts.

Here’s how I created a fairly complete solution.

First I added the following code where I wanted the future dated events to display.

< ?php
$today = current_time('mysql', 1);
if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today'") ) :
echo "<ul><li>Scheduled Events";
foreach ($scheduled as $post)
{
if ($post->post_title == '')
$post->post_title = sprintf(__('Post #%s'), $post->ID);
echo "<ul><li><a href='news/?p=$post->ID' title='" . __('Edit this post') . "'>$post->post_title</a> in " . human_time_diff( current_time('timestamp', 1), strtotime($post->post_date_gmt) )  . "</li></ul></li></ul>";
}
endif;
?>

This displays the post title with the permalink and a countdown to the event.

Next I needed a way to allow visitors to view the future dated event by clicking on the permalink. Luckily I found the perfect plugin for this called View Future Posts. This plugin was meant for allowing administrators to see future dated posts but the author set it up to configure the user level to view future dated posts and to display the post only if accessed by the permalink. Perfect!

Now I have

Categories: WordPress Plugins

This post was written by . You can visit the for a short bio, more posts, and other information about the author.

Get backlinks to your Blog!

Promote Your Blog

If you are looking to promote your blog and get high quality backlinks from a PR6 2003 domain then Blogsearchengine.com is for you. For as little as $14.99 you can submit your blog and have a review written and published there with a backlink to your website or blog, we accept all niche!


Comments Closed

Comments

  1. AsceticMonk says: 4/15/2005

    Cool! In some sense, it resembles to my recent plug-in Coming Soon, which is a plug-in to display drafts and accompanied with a progress meter.

  2. Michael Moncur says: 4/16/2005

    Thanks for the link! I’m glad this plug-in is turning out to be useful to more people than just me.