WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Shortcodes [locations_list] (2 posts)

  1. ciccimanolesta
    Member
    Posted 2 years ago #

    Is there a way to filter locations by category? or by a custom field?

    Thanxs

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

  2. agelonwl
    Member
    Posted 2 years ago #

    you can do it by custom field using hooks/filters.

    e.g. pasting this to your theme functions.php (modify as needed) might work for you

    usage: [locations_list custom="Concert Stage"]

    add_filter('em_locations_get_default_search','my_em_cf_get_default_search',1,2);
    function my_em_cf_get_default_search($searches, $array){
    	if( !empty($array['custom']) ){
    		$searches['custom'] = $array['custom'];
    	}
    	return $searches;
    }
    
    add_filter('em_locations_get','my_em_cf_events_get',1,2);
    function my_em_cf_events_get($locations, $args){
    	if( !empty($args['custom']) ){
    		foreach($locations as $location_key => $EM_Location){
    			if( !in_array($args['custom'],$EM_Location->location_attributes) ){
    				unset($locations[$location_key]);
    			}
    		}
    	}
    	return $locations;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic