Support » Fixing WordPress » Show Posts With Future Dates

  • Is there a parameter for the query_posts() tag that shows posts which have dates from the future? I am going to use an archive-like template page as a calendar.

    The problem is posts disappear when they have future dates.

    Thanks for any help.

Viewing 14 replies - 1 through 14 (of 14 total)
  • pdlr,
    Yes, you should be able to use:
    query_posts('post_status=future,publish');

    This worked for me in 2.3 when called before the loop in a template page. This parameter will accept the following values – each value should be separated by a comma:

    draft
    pending
    future
    inherit
    private
    publish

    Omg I’ve just posted the exact same problem !

    But im total noob to php and wordpress could you please explain where I insert this ?

    I currently have this right before the loop on the archive.php template:

    <?php if (is_category()) { $posts = query_posts($query_string . ‘&post_status=future,publish&orderby=date&showposts=-1’); } ?>

    Past date categories are working but future date calendar catagory is still showing “Error 404 – Not Found”

    I’ll keep messing with this and post the results if I get it right.

    Thanks for your help, Mfields

    pdlr,
    Hi. Sorry for the mixup, but I just noticed that you said your version 2.0. I downloaded this version and the solution that I posted above will not work with your version. post_status is handled in the following manner in 2.0:

    if ( $this->is_attachment ) {
    			$where .= ' AND (post_status = "attachment")';
    		} elseif ($this->is_page) {
    			$where .= ' AND (post_status = "static")';
    		} elseif ($this->is_single) {
    			$where .= ' AND (post_status != "static")';
    		} else {
    			$where .= ' AND (post_status = "publish"';
    
    			if (isset($user_ID) && ('' != intval($user_ID)))
    				$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
    			else
    				$where .= ')';
    		}

    In other words “It’s totally locked in there and there’s no way to easily access it”

    I’m using wordpress-2.3.2 mfields can you help me please ?

    mfields, i noticed that is an if loop for attachment pages. where is that code? i don’t seed it in my archive page.

    ok, in wp-includes/classes.php line 588:

    //only select past-dated posts, except if a logged in user is viewing a single: then, if they
    		//can edit the post, we let them through
    		if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
    			$where .= " AND post_date_gmt <= '$now'";
    			$distinct = 'DISTINCT';
    		}

    Does this have anything to do with it? How can it be changed?

    OK! = )

    In the code above,

    $where .= " AND post_date_gmt <= '$now'";

    should be deleted. This will allow for future posts to be displayed in wordpress 2.0.2

    pdlr,
    The code I posted was from classes.php. Is there any reason you can’t upgrade? I really do not feel comfortable giving you advice on how to modify core files as this is something that I never do. My advice to you would be to upgrade to a version where this functionality is supported by query_posts(). In my experience it is best to work with WordPress – not against it 🙂

    I will upgrade in the next week or two, just need to patch this for the next few days. But this works just fine. Thanks for your help, mfields.

    millik1

    (@millik1)

    Here’s my solution which I use on a number of websites to display event / gig lists with future dates, without using plug-ins or having to modify core WP files.

    http://www.keithmillington.co.uk/wordpress/?p=22

    Thanks to ‘mfields’ who put me on to the idea of exploiting the ‘post_status=future’ function in the first place.

    I’m using WP 2.6 and I tried this:

    <?php if (have_posts('post_status=future,publish')) : while (have_posts('post_status=future,publish')) : the_post(); ?>

    yet it didn’t display future posts.

    ok, so i put

    <?php query_posts('post_status=future,publish'); ?>

    in my index page and it worked. But another problem came up that I can’t use the NEXT and PREVIOUS links. In other words, I can’t use page numbers.

    How do I fix this or use a different method to get scheduled posts?

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Show Posts With Future Dates’ is closed to new replies.