array( 'name' => __( 'Agents' ), 'singular_name' => __( 'Agent' ) ), 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'), 'show_ui' => true, 'public' => false ) ); register_taxonomy( 'agent_location', 'agent', array( 'hierarchical' => true, 'label' => 'Agent Location', 'query_var' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => 'agent-location', 'with_front' => true ) ) ); register_taxonomy( 'agent_project', 'agent', array( 'hierarchical' => true, 'label' => 'Agent Project', 'query_var' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => 'agent-project', 'with_front' => true ) ) ); register_taxonomy( 'agent_size', 'agent', array( 'hierarchical' => true, 'label' => 'Agent Size', 'query_var' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => 'agent-size', 'with_front' => true ) ) ); } function agent_list_shortcode($atts){ extract( shortcode_atts( array( 'count' => -1, ), $atts) ); if(!empty($_GET['a_location'])) { $a_location = $_GET['a_location']; } else { $a_location = ''; } if(!empty($_GET['a_project'])) { $a_project = $_GET['a_project']; } else { $a_project = ''; } if(!empty($_GET['a_size'])) { $a_size = $_GET['a_size']; } else { $a_size = ''; } if(!empty($_GET['a_name'])) { $a_name = $_GET['a_name']; } else { $a_name = ''; } $tax_query = array('relation' => 'AND'); if(!empty($a_location)) { $tax_query[] = array( 'taxonomy' => 'agent_location', 'fields' => 'id', 'terms' => $a_location ); } if(!empty($a_project)) { $tax_query[] = array( 'taxonomy' => 'agent_project', 'fields' => 'id', 'terms' => $a_project ); } if(!empty($a_size)) { $tax_query[] = array( 'taxonomy' => 'agent_size', 'fields' => 'id', 'terms' => $a_size ); } $q = new WP_Query( array( 'posts_per_page' => $count, 'post_type' => 'agent', 's' => $a_name, 'tax_query' => $tax_query ) ); $list = ''; $list .= ''; $list .= '
'; while($q->have_posts()) : $q->the_post(); $idd = get_the_ID(); $custom_field = get_post_meta($idd, 'custom_field', true); $post_content = get_the_content(); $list .= '

' .do_shortcode( get_the_title() ). '

Lorem ipsum dolor sit amet consectetur adipisicing elit. Totam excepturi magni culpa illum velit eaque asperiores quidem. Iure ab reiciendis saepe temporibus aperiam, quisquam magni commodi harum incidunt sed libero?

'; $agent_location = get_the_terms( get_the_ID(), 'agent_location' ); if($agent_location && ! is_wp_error( $agent_location )) { $locations_array = array(); foreach ( $agent_location as $location ) { $locations_array[] = $location->name; } $locations = join( ", ", $locations_array ); $list .= '

Locations: '.$locations.'

'; } $agent_project = get_the_terms( get_the_ID(), 'agent_project' ); if($agent_project && ! is_wp_error( $agent_project )) { $projects_array = array(); foreach ( $agent_project as $project ) { $projects_array[] = $project->name; } $projects = join( ", ", $projects_array ); $list .= '

Projects: '.$projects.'

'; } $agent_size = get_the_terms( get_the_ID(), 'agent_size' ); if($agent_size && ! is_wp_error( $agent_size )) { $size_array = array(); foreach ( $agent_size as $size ) { $size_array[] = $size->name; } $sizes = join( ", ", $size_array ); $list .= '

Sizes: '.$sizes.'

'; } $list .='
Contact agent
'; endwhile; $list.= '
'; wp_reset_query(); return $list; } add_shortcode('agents', 'agent_list_shortcode');