• I have been trying to use the code below to display posts that have today’s date in the Custom Field I created named ‘Date’. I only want to display today’s events, not anything in the past or future. I’m not sure what I need to modify to get this working. I am definitely not a PHP programmer, so I could use some help.

    // Get today's date in the right format
    				$todaysDate = date('m/d/Y g:i:a');
    
    echo '<h3 class="widgettitle">Today’s Events</h3>';
    echo '<ul>';
    query_posts('showposts=5&category_name=events&tag=main,lucasville,wheelersburg,newboston,southwebster,computer,kids&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');
    if ( have_posts() ) : while ( have_posts() ) : the_post();

    Thanks,
    T

Viewing 4 replies - 1 through 4 (of 4 total)
  • does your custom field value have the exact same format as your date function here:

    $todaysDate = date('m/d/Y g:i:a');
    Thread Starter iwildeachit

    (@terryit3)

    I’ve made a small change.. my function is now:
    ('m/j/Y g:i:a')

    I am trying to add the date in the custom field like this:
    11/3/2010 7:00pm

    I have a feeling the extra colon after (g:i) is causing the problem, but I can’t out how to format my PHP date for the function.
    If I remove the g:i:a section, and add just a date, it works perfectly.

    Thread Starter iwildeachit

    (@terryit3)

    I figured out a way around doing it this way.
    Problem resolved.

    Thread Starter iwildeachit

    (@terryit3)

    Ok, I take that back. My problem is not resolved. I tried to make a custom field for the date and another custom field for the time and have it sort by time, but that doesn;t work either.

    Is there a way I can try to get my original function working. I would like to have my date formatted like this (11/3/2010 7:00pm) when it displays on the page, as well as being sorted ascending and in order from earliest time to latest time.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query to show events from today.’ is closed to new replies.