Support » Fixing WordPress » How to show posts in categories when timestamp has been set to a future date?

  • Is it possible (through a hack maybe) for the category view to show future events?

    Here’s the situation. I’m using WP to manage the website for a sports league. I’m using the EventCalendar plugin to manage the calendar/schedule for the league. I associate each game with the Events category (the category that the plugin monitors) as well as a category for each team involved in the games. The plugin works by looking at the timestamp (which gets set to the date of the event) to determine when the event occurs. What I was hoping to be able to do was allow the teams to be able to click on their category to see all of their games (their schedule), but the category view doesn’t show posts with timestamps in the future. Any way to do this? I could modify the way the category view function works (if I could find it 😉 – I haven’t looked that hard). Thought I’d ask for suggestions before I started hacking.

    Thanks for any help. Ohh yeah. Here’s the site. It’s a WIP. Just installed yesterday.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Got it to work by changing the following code in wp-includes\classes.php from this

    //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))

    to this

    //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) && empty($q[‘cat’]))

    Looks like it’ll do the trick. Only problem I see is it’ll show all post for all categories. Not sure if that’s going to be a problem for me or not. If anyone has any better suggestions, please let me know. Thanks.

    The code posted by speedphreak is good. I made a simple modification so that the code would only apply to my “events” category.
    //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 ($cat_id==xxx) { //where xxx=the category id of your events category
    if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID) && empty($q['cat']))
    $where .= " AND post_date_gmt <= '$now'";
    $distinct = 'DISTINCT';
    }
    } else {
    if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
    $where .= " AND post_date_gmt <= '$now'";
    $distinct = 'DISTINCT';
    } }

    Can anyone give some guidance on how to do this in WP 2.1.2?

    I’ve located the relevant function in wp-includes\query.php but the code has changed and I’m having a hard time deciphering it.

    I would also love a solution to change this for WP 2.1.2 I am trying to use posts as a calendar and I would like to sort them by the timestamp.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to show posts in categories when timestamp has been set to a future date?’ is closed to new replies.