Support » Fixing WordPress » Display future post on single pageview?

  • Resolved Jacorre


    I’m able to display future posts using post_status=future within a query posts loop. I’m also able to display future posts in my RSS feed. The problem is that if someone clicks on the future post in the RSS feed, it can’t bring them to the post because it’s not technically posted yet.

    Is there any way to change the single.php template file to allow for viewing future posts?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Have you tried adding a similar custom query to single.php?

    I have tried that and it ends up displaying all posts instead of the one I clicked on.

    Well, you’d obviously need to modify the query so that it was only calling a single post…

    And how would one do that?

    On the single.php template file, I try placing the query_post(“post_status=publish,future”) before the loop because I would still want to published posts to be viewed as well. But when I click on a post from an archive page, it ends up giving me all the posts instead of just the one I clicked on.

    global $query_string;
    query_posts( $query_string . 'post_status' => array('publish','future') );

    Unless I’m doing something wrong, that’s not working. I used the following on my single.php template file:

    <?php global $query_string;
    query_posts( $query_string . 'post_status' => array('publish','future') );
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    I found a solution. I added the following to my functions.php file:

    /* 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');

    Thanks for your help though!

    But if I want apply this filter only for one category??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display future post on single pageview?’ is closed to new replies.