• Resolved summerbrother

    (@summerbrother)


    Unfortunately there is no possibility to assign categories at the locations.
    So I used the #_LATT to assign me a select field with categories.
    Now I want to filter the output of the location-list by the #_LATT.
    In shortcode it does not work.
    So I wrote a wp-query. The wp-query filters correctly, but I can’t get the output of e.g. the street, but php the_title works.

    I would prefer something like #_LOCATIONADDRESS or
    <?php echo $EM_Location->location_address ?> , but this will not work in the loop.

    Does anyone else have an idea how to make this work?

Viewing 1 replies (of 1 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    Hi,

    This might not work out of the box but can help you get started:

    1.

    
    /*to use post categories replace EM_TAXONOMY_CATEGORY with 'category' */
    function em_location_cats(){
     register_taxonomy_for_object_type(EM_TAXONOMY_CATEGORY, EM_POST_TYPE_LOCATION);
    }
    add_action('init','em_location_cats');
    

    2.

    
    add_filter('em_locations_get_default_search','my_em_styles_get_default_search',1,2);
    function my_em_styles_get_default_search($searches, $array){
    	if( !empty($array['location_category']) ){
    		$searches['location_category'] = $array['location_category'];
    	}
    	return $searches;
    }
    
    add_filter('em_locations_get','my_em_custom_events_get',1,2);
    function my_em_custom_events_get($locations, $args){
      if( !empty($args['location_category']) ){
        $search = explode(',',$args['location_category']);
        foreach($locations as $location_key => $EM_Location){	
          $terms = array();
          $term_array = array();
          $terms = get_the_terms( $EM_Location->post_id , EM_TAXONOMY_CATEGORY );
          if ( is_array($terms) ){	
             foreach( $terms as $term ) {
                if ( !in_array($term->term_id, $search) ){
                  unset($locations[$location_key]);
                }
             }
          }else{
            unset($locations[$location_key]);
          }
        }
      }
      return $locations;
     }
    

    Usage: [locations_list location_category=”x”] where x is the category id

Viewing 1 replies (of 1 total)

The topic ‘Categories for Locations’ is closed to new replies.