Hack to show future post like single.php
Description
This code comes in handy when wanting to display future events on a website. The PHP whould go in the functions.php file and the html should go in the custom single.php file. Code was used in mtsinaicogic.org
HTML Source Code
<!-- Post Starts -->
<?php
query_posts('cat=3&posts_per_page=-1&post_status=future&orderby=date&order=asc'); // query to show all posts independent from what is in the center;
if (have_posts()) :
global $post;
while (have_posts()) :the_post(); ?>
<!--Post attributes Start-->
<!--Post attributes End-->
<!--Post Details End-->
<?php endwhile; ?>
<?php else : ?>
Sorry, but there are no upcoming events in this category
<?php endif; ?>
<!--End-->
PHP Source Code
<?php
/* Show future posts */
function show_future_posts($posts)
{
global $wp_query, $wpdb;
if(is_single() && $wp_query->post_count == 0)
{
$posts = $wpdb->get_results($wp_query->request);
}
return $posts;
}
add_filter('the_posts', 'show_future_posts');
?>