Support » Plugin: Events Manager » Custom query ignores scope=future

  • Resolved taras_bulba



    I’m trying to make a custom query to take the future events and display them in another custom plugin I’ve made. I’m using this query, but it will bring all the events, future and past, and ignore the scope. What’s wrong here? Thanks for your help.

    $query_args = array(
            'post_type' => $post_type,
            'posts_per_page' => $posts_per_page,
            'category_name' => $category_name,
            'tag' => $tag,
            'orderby' => $orderby,
            'order' => $order,
    	'scope' => 'future',
            'meta_key' => '_thumbnail_id' // Should pull only content with featured images
        /* Allow the query args to be filtered */
        $query_args = apply_filters( 'arconix_flexslider_query_args', $query_args );
    	$fquery = new WP_Query( $query_args );

Viewing 11 replies - 1 through 11 (of 11 total)
  • I’ve read that thread and a couple more on the same issue, but I haven’t been able to figure out a solution by reading them.

    I think my problem is more simple that the one in that thread. I just want to query the events with scope=future, but the query comes with every event.

    What confuses me a lot is that this is not a complicated query, I don’t know if I am missing something too obvious here in my query.

    sorry, I’m afraid that I can’t help you with custom codes.

    Well, is not THAT custom, I just want to query the events with scope = future using WP_Query

    Is it that difficult or weird what I’m trying to do?

    What I need to do is this:

    $EM_Events = EM_Events::get( array(‘scope’=>’future’) );

    But using WP_Query

    Any help?

    Let me up this to see if I can get some help.

    No luck; still stuck trying to query the events with scope = future using WP_Query

    maybe this snippet can give you some idea –

    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
    	$id = $query->post->ID;
    	echo '<li>';
    	echo get_the_title($id);
    	echo ' - '. get_post_meta($id, '_event_start_date', true);
    	echo '</li>';
    	// Reset Post Data

    Tnx for the snippet @agelonwi, helped me on my way. Only thing is that a meta_query needs to have a double array apparently. Example from:

    $args = array(
    	'post_type' => 'product',
    	'meta_query' => array(
    			'key' => 'color',
    			'value' => 'blue',
    			'compare' => 'NOT LIKE'
    $query = new WP_Query( $args );

    So the resulting query arguments would be something like:

    $args = array(
    	'post_type' => 'event',
    	'posts_per_page'         => '4',
    	'meta_query' => array(
    			'key' => '_start_ts',
    			'value' => current_time('timestamp'),
    			'compare' => '>=',
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Custom query ignores scope=future’ is closed to new replies.