WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Combined WP_Query of events and locations (10 posts)

  1. Chantal Coolsma
    Member
    Posted 1 year ago #

    A customer has a grid based homepage of both locations and events. They are shown based on post date (so newest location or event on top). I used WP_query, but now it shows past events too.

    Is there a simple way to filter those events? So event_end_date is history, don't show the event.

    Any ideas?

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

    easiest way is to use $EM_Events = EM_Events::get( array('scope'=>'future') );

    http://wp-events-plugin.com/documentation/advanced-usage/

  3. Chantal Coolsma
    Member
    Posted 1 year ago #

    That is only for events. I have a query_posts loop now, which shows 12 items on each page. This are the post types 'post', 'event' and 'location'. However this could show events which are past. It just queries those post types and show them with the newest published on top.

    There must be a way to combine two queries:
    - events (future events)
    - locations

    Searched the web, found some examples but none of them work.

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    this is work in progress, but maybe the function build_wpquery_conditions in file classes/em-object.php will help you figure it out, as it builds a WP_Query array.

  5. Chantal Coolsma
    Member
    Posted 1 year ago #

    Any news on this? I have a customer who wants to pay for it if you can give it some priority.

    I am not a die-hard coder, so I need a simple and easy way to accomplish this fast.

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    given we're fully focused on working on the plugin with established priorities we can't do that atm.

    otherwise you can try http://jobs.wordpress.net, a dev can probably figure out from what we've already done (e.g. in classes/em-posts-admin.php) to see what's needed to build your specific queries.

  7. Chantal Coolsma
    Member
    Posted 1 year ago #

    I tried. It's not clear to me. I have a WP_Query now, but this shows also past events. This must be changed, otherwise my customer will stop using Events Manager.

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    I can't do this for you, but the specific bit on WP_Query to edit is in the file above:

    }elseif ($scope == "future"){
    	$today = strtotime(date('Y-m-d', $time));
    	if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
    		$query[] = array( 'key' => '_start_ts', 'value' => $today, 'compare' => '>=' );
    	}else{
    		$query[] = array( 'key' => '_end_ts', 'value' => $today, 'compare' => '>=' );
    	}
    }

    which you then add like

    $wp_query->query_vars['meta_query'] = $query;

  9. Chantal Coolsma
    Member
    Posted 1 year ago #

    I think I run in the same problem as that Infinite Scroll thingy. meta_query gives all or nothing.

    $args = array(
    		'post_type' => array( 'event','location','post' ),
    		'orderby' => 'date',
    		'order' => 'DESC',
    		'posts_per_page' => 12,
    		'paged' => get_query_var('page'),
    		'scope' => 'future'
    );
    
    query_posts($args);

    As soon as I add meta_query, it even ignores locations. They don't have a start or end date.

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    since locations don't have dates, you can't expect to search locations and events in the same way based on a date, that's just how it is.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.