WordPress.org

Support

Support » Plugins and Hacks » Events Manager » [Resolved] how to filter em_events by attributes?

[Resolved] how to filter em_events by attributes?

  • i am trying to display events which have a specific attribute only. this does not work:

    <?php
    if (class_exists('EM_Events')) {
    	echo EM_Events::output( array(
    		'limit'=>20,
    		'recurring'=> 0,
    		'meta_key' => 'Home'
    		'meta_value' => 'yes'
    	) );
    }
    ?>

    as you can see, i just want to display those events which have the attribute “Home” set to “yes” as shown here: http://adrop.in/F8j

    any ideas? THANKS!

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • caimin_nwl

    @caimin_nwl

    NetWebLogic Support

    You’re missing a coma after the ‘Home’ part.

    Yea thats right but even with comma it won’t work

    caimin_nwl

    @caimin_nwl

    NetWebLogic Support

    A better way to do this might be to use a modified WP query. This is untested but something like this should work:

    $args = array(
    		'post_type' => 'event',
    		'meta_key' => 'Home',
    		'meta_value' => 'yes');
    
    	$query = new WP_Query( $args );

    …and then into a normal Loop.

    These code examples might help:
    http://wordpress.org/support/topic/custom-query-ignores-scopefuture?replies=10

    yep. thats the ONLY way it would work. already found and tested this solution BUT it does not support the “recurring” paramter :(. i want the best from both worlds: recurring and meta_key 😀

    angelo_nwl

    @angelo_nwl

    NetWebLogic Support

    you can add event-recurring

    e.g.

    'post_type' => 'event,event-recurring',

    ah nice. i did not know about that. thats my final wp_query:

    new WP_Query(array(
    	'post_type' => 'event-recurring',
    	'posts_per_page' => 5,
    	'meta_key' => 'Home',
    	'meta_value' => 'yes'
    ));

    this shows me one instance of a recurring event with the custom post type “Home” and value “yes”. perfect.
    thank you angelo!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] how to filter em_events by attributes?’ is closed to new replies.
Skip to toolbar