Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* POST CATEGORIES
- * USAGE: [locations_list postcategory="4"]
- */
- add_filter('em_locations_get','my_em_em_locations_get_cats',10,2);
- function my_em_em_locations_get_cats($EM_Locations, $args){
- if( !empty($args['postcategory']) ){
- $search = explode(',',$args['postcategory']);
- foreach($EM_Locations as $location_key => $EM_Location){
- $terms = array();
- $term_array = array();
- $terms = get_the_terms( $EM_Location->post_id , 'category' );
- if ( is_array($terms) ){
- foreach( $terms as $term ) {
- if ( !in_array($term->term_id, $search) ){
- unset($EM_Locations[$location_key]);
- break;
- }
- }
- }else{
- unset($EM_Locations[$location_key]);
- }
- }
- }
- return $EM_Locations;
- }
- add_filter('em_locations_get_default_search','my_em_em_locations_get_default_search_cats',1,2);
- function my_em_em_locations_get_default_search_cats($searches, $array){
- if( !empty($array['postcategory']) ){
- $searches['postcategory'] = $array['postcategory'];
- }
- return $searches;
- }
- /* POST CATEGORIES */
- /*
- * POST TAGS
- * USAGE: [locations_list posttag="4"]
- */
- add_filter('em_locations_get','my_em_em_locations_get_tag',10,2);
- function my_em_em_locations_get_tag($EM_Locations, $args){
- if( !empty($args['posttag']) ){
- $search = explode(',',$args['posttag']);
- foreach($EM_Locations as $location_key => $EM_Location){
- $terms = array();
- $term_array = array();
- $terms = get_the_terms( $EM_Location->post_id , 'post_tag' );
- if ( is_array($terms) ){
- foreach( $terms as $term ) {
- if ( !in_array($term->term_id, $search) ){
- unset($EM_Locations[$location_key]);
- break;
- }
- }
- }else{
- unset($EM_Locations[$location_key]);
- }
- }
- }
- return $EM_Locations;
- }
- add_filter('em_locations_get_default_search','my_em_em_locations_get_default_search_tag',1,2);
- function my_em_em_locations_get_default_search_tag($searches, $array){
- if( !empty($array['posttag']) ){
- $searches['posttag'] = $array['posttag'];
- }
- return $searches;
- }
- /* POST TAGS */
- function my_em_own_taxonomy_register(){
- register_taxonomy_for_object_type('category',EM_POST_TYPE_LOCATION);
- register_taxonomy_for_object_type('post_tag',EM_POST_TYPE_LOCATION);
- }
- add_action('init','my_em_own_taxonomy_register',100);
Add Comment
Please, Sign In to add comment