Date comparison

Home Forums Calendar Products Events Calendar PRO Date comparison

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #396438
    aling
    Participant

    Hello everyone!
    So our company is currently use Events Calendar pro. Right now for the custom fields section, I have an option to display the event on the homepage or not. If yes is selected, it gets generated/added to the plugin we use to display an event carousel called bxSlider.

    Currently, whenever an event ends, I have to manually go in and select no for “Display on homepage”. I was wondering if anyone knew of a way to make it so that it would automatically fall off once the event date & time passes?

    This is the query that we currently have. I was thinking that I would have to add in the “if(strtolower($linkr)==’yes’)” something along the lines of “and if the tribe_get_end_date > today” but I don’t know how to write that part.

    <?php $query_str = “SELECT distinct wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = ‘_EventStartDate’ AND wposts.post_type = ‘tribe_events’ ORDER BY wpostmeta.meta_value ASC “;

    $posts = $wpdb->get_results( $query_str );
    foreach($posts as $post){
    setup_postdata($post);
    $id=get_the_ID();
    $linkr=get_post_meta($id,’_ecp_custom_3′,true);
    if (strtolower($linkr)==’yes’) {
    $link=get_permalink($id);
    echo “”;
    }
    }
    ?>

    Website: http://www.lightgroup.com

    #398441
    aling
    Participant

    Alright, so here is what I wrote and it seemed to work but am no sure if this is correct way of writing it or not.

    $todayDate = date(“Y-m-d H:i:s”);
    $eventDate=get_post_meta($id,’_EventStartDate’, “Y-m-d H:i:s”);
    if ((strtolower($linkr)==’yes’) && ($eventDate >= $todayDate))

    #398856
    aling
    Participant

    Forgot to close this out.

    #983405
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Date comparison’ is closed to new replies.