Viewing 11 replies - 1 through 11 (of 11 total)
  • You can easily make your own SQL-query that fetches future posts by the status ?future?:

    global $wpdb;
    $mysql = "SELECT wposts.* FROM $wpdb->posts wposts WHERE wposts.post_status LIKE 'future' ORDER BY wposts.post_date ASC";
    $futureposts = $wpdb->get_results($mysql, ARRAY_A);
    	if($futureposts) :
    		foreach ($futureposts as $future) :
    			echo date('d.m.Y', strtotime($future['post_date'])).': ';
    			echo '<a href="'.get_permalink($future['ID']).'">';
    			echo $future['post_title'];
    			echo '</a><br />';
    		endforeach;
    	endif;

    Put this in a template-file, and it will output all future posts with the future-date and links to the post. No need to muck about with the core.

    Thread Starter yochee

    (@yochee)

    no, this doesn′t help, because the posts won′t show up in the rss-feed.

    actually, i did something like this but because of the rss-thing I′m not quite satisfied with it.

    it would be much easier if there would be the possibility to show/hide future posts/drafts in the admin panel

    Hi

    Did you solved the problem with future post in RSS feed? I’m having the same problem.

    I agree about this, for example I’m posting movie information about films coming in the future. It’s no use to me that movie only being published live for reading (on that date) 6 months from now that I write for people to know about now. I still want to add it to the correct date it gets released for watching, so dates match-up. But I want people to be able to read that post now, not in 6 months time when the movie is already with us.

    There should be a default setting in wordpress that shows all future posts still live to be read, or at least to give you the option to do it, or not.

    I’m agree.
    If future posts could be readed, we can use them as events. The easiest way to make an agenda.
    But only if logged as admin I can read them.

    I know there are events plugins but this is enought for me, I do not need extra options.

    Greetings

    The following code is a good starting point. Just add it to your functions.php file.

    function show_any_post_status($queryVars) {
    	$queryVars->query_vars['post_status'] = 'any';
    	return $queryVars; // Return our modified query variables
    }
    add_filter('pre_get_posts', 'show_any_post_status');

    There are a number of issues with this code depending on your theme and particular situation. There is no way to show a particular combination of post statuses, like ‘publish’ and ‘future’. So this code shows ALL of them, including drafts (but not Trash).

    Now I can make a list of publish and future post, but I cannot make them viewable on a single page, I can only see publish post and if I click on a future one it is show the most future one.

    Any suggestion?

    I think ht ebest way to go about showing events is to not include publish date altogether. For one reason, there is so many other functions that rely on the publish date to show the post.

    My suggestion is that you should use a post-type or custom field with numbers representing the date (may 3rd, 2010 = XXXXYYZZ = 20100503 )and have the number parsed on the front (XXXX = yeaar, YY = monnth, ZZ = day ), and then you could sort those, include/exclude etc.

    You won’t enocunter nearly as many problems, and you won’t have to rely on functions that deal with core pieces of the wordpress cms. As well, you could add custom fields to rss feeds.

    I think adding custom fields to rss feeds would be the easiest way for now. In fact, I do it this way for months and as long as there’s no cool workaround, it will be the best to keep it like it.

    I am working on something similar to this, with roughly the same approach joehuffman2 suggests. I have a custom post type called “calendar”, where I have a meta field for date, on the form YYYY.MM.DD

    On the front page, I show 10 of these calendar events in the sidebar, sorted by date, ascending, so the first event will be on top, and this far it works fine. But how can I make them disappear when that date has passed? I’d like the events to still be published, I just dont want them in the calendar on the front page

    This is the query I use now, which works, except that the events dont disappear when I’d like them to:

    post_type=calendar&posts_per_page=10&orderby=meta_value&meta_key=date&order=ASC

    I’m thinking something like

    $today = date("Y.m.d") ;
    query_posts('post_type=calendar&posts_per_page=10&orderby=meta_value&meta_key=date&order=ASC&meta_compare=>today');

    but I’m obviously doing something wrong.

    I probably need to get this explained _really_ basic… PHP & such aint my strong side…

    It turned out to be as simple as this:

    $today = date("Y.m.d") ;
    query_posts("post_type=calendar&orderby=meta_value&meta_key=eventdate&order=ASC&meta_compare=>=&meta_value=$today"

    For anyone else struggling with similar things: Note the double quotes around the query instead of single quotes, and

    meta_compare=>=&meta_value=$today

    not just (correct form above, wrong below)

    meta_compare=>$today

    What went wrong at first in addition to the single quotes, was how to use the “meta_compare”. I figured it would use the same meta_value I already had chosen, but it must be chosen specifically for the meta_compare also.

    Here I have a custom post type called “calendar”, with a custom field called “eventdate” where the event date is entered on the form YYYY.MM.DD. Then this query orders the calendar events according to the eventdate, only showing events where the “eventdate” is today or in the future.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘making a event list with future dates wordpress’ is closed to new replies.