• Resolved xxaimsxx

    (@xxaimsxx)


    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 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 "<li><a href='{$link}' title=''>";
    			the_post_thumbnail();
    			echo "</a></li>";
    		}
    	}
    ?>

    Here is our site: http://www.lightgroup.com

Viewing 1 replies (of 1 total)
  • Thread Starter xxaimsxx

    (@xxaimsxx)

    Alright, so here is what I wrote and it seemed to be working!

    date_default_timezone_set('America/Los_Angeles');
    $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))
Viewing 1 replies (of 1 total)
  • The topic ‘Plugin: The Events Calendar] Need help comparing dates’ is closed to new replies.