• Resolved jojo2203

    (@jojo2203)


    How can I retrieve the current date of an event and then continue to use it? would like to query the date and then see if a post was written on this day and if so a link in the event description show. how could i do shortcodes or custom post types i’m a newbie, please help me with ideas.

    Thanks. jojo

Viewing 1 replies (of 1 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    just to confirm, did you mean using php code to get the event start date? if yes, we are quite limited with regards to custom coding as per the support policy but hopefully this user shared snippet can help you get started

    
    function my_em_wp_query(){
    	$args = array(
    		'post_type' => 'event',
    		'posts_per_page' => 100,
    		'meta_query' => array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '>=', 'type'=>'numeric' ),
    		'orderby' => 'meta_value_num',
    		'order' => 'ASC',
    		'meta_key' => '_start_ts',
    		'meta_value' => current_time('timestamp'),
    		'meta_value_num' => current_time('timestamp'),
    		'meta_compare' => '>='
    	);
    
    	// The Query
    	$query = new WP_Query( $args );
    
    	// The Loop
    	while($query->have_posts()):
    	$query->next_post();
    	$id = $query->post->ID;
    	echo '<li>';
    	echo get_the_title($id);
    	echo ' - '. get_post_meta($id, '_event_start_date', true);
    	echo '</li>';
    	endwhile;
    
    	// Reset Post Data
    	wp_reset_postdata();
    }
    add_shortcode('em_wp_query','my_em_wp_query');
    
Viewing 1 replies (of 1 total)
  • The topic ‘current date of an event for further use’ is closed to new replies.