• Tim Hyde

    (@livingos)


    Event Maker seems to break ability to use WP Query object to query multiple post types.

    I am trying to do this:
    `$query = new WP_Query( array(
    ‘post_type’ => array( ‘post’, ‘page’,’event’)

    );`

    But this only returns events, unless I disable Event Maker’s extend_pre_query in query.php. The pre query filter seems to prevent other post types from appearing. Presumably because they cannot match all the extra query params that get thrown into query by Event Maker.

    Any way round this?

    https://ww.wp.xz.cn/plugins/events-maker/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author dFactory

    (@dfactory)

    Please try changing line 372 of includes/query.php from this:

    // does query contain post type as a string or post types array
    		if(is_array($post_types))
    			$run_query = (bool)array_intersect($post_types, apply_filters('em_event_post_type', array('event')));
    		else
    			$run_query = in_array($post_types, apply_filters('em_event_post_type', array('event')));

    into this:

    // does query contain post type as a string or post types array
    		if(is_array($post_types) && !array_diff($post_types, apply_filters('em_event_post_type', array('event'))))
    			$run_query = (bool)array_intersect($post_types, apply_filters('em_event_post_type', array('event')));
    		else
    			$run_query = in_array($post_types, apply_filters('em_event_post_type', array('event')));

    And please report if it solved the issue.

    Thread Starter Tim Hyde

    (@livingos)

    Yep, I had already made a similar change to make it work.

    Your code also works and allows my Query to work properly now.

    Thanks for quick response.

    I have been using The Event Calendar on most projects, but have grown tired of its inability to work other things. I wanted a simpler solution that I can integrate into bespoke projects, that doesn’t pollute the WordPress dashboard for clients. Not convinced this is it it yet, but giving it a go on latest project.

    Do you have this project on github or bitbucket? I’d be interested in forking and contributing if it fits.

    Plugin Author dFactory

    (@dfactory)

    Thanks Tim.

    Any suggestions or contributions are welcome.

    We’re not running this on Github, but we have some plans to do that in the future.

    When it comes to the Events Calendar and Events Maker – we created it mainly because of the frustration of using EC or other event management plugins. Wanted something easy to use for clients but at the same time powerful for us, the developers (for example: try the em_event_post_type filter). At the same time we needed it to be fully compatible with Polylang and WPML. So here it is.

    Hope you and others’ll like it.

    Regards,
    Bartosz

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP Query for multiple post types does not work with Event Maker’ is closed to new replies.