WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] how to filter em_events by attributes? (7 posts)

  1. nicmare
    Member
    Posted 1 year ago #

    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/

  2. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    You're missing a coma after the 'Home' part.

  3. nicmare
    Member
    Posted 1 year ago #

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

  4. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    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

  5. nicmare
    Member
    Posted 1 year ago #

    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 :D

  6. angelo
    NetWebLogic Support
    Posted 1 year ago #

    you can add event-recurring

    e.g.

    'post_type' => 'event,event-recurring',
  7. nicmare
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic