'location', 'orderby' => 'name', 'order' => 'ASC' ); $category_ats = get_categories($args2); $args3 = array( 'taxonomy' => 'first_letter', 'orderby' => 'name', 'hide_empty' => false, 'order' => 'ASC' ); $category_first = get_categories($args3); //die(); ?>
Sort By:
name."' data-slug='".$category_cats->slug."' id='loc_".$category_cats->term_id."' name='category_cats[]' value='".$category_cats->term_id."'>"; } ?>
Filter:
$iids){ if(!empty($iids)){ $selected_cat[]=$iids; } } } $_sft_first_letter = isset($_REQUEST['_sft_first_letter'])? trim($_REQUEST['_sft_first_letter']):""; $selected_txt = isset($_REQUEST['sf_search_txt'])? trim($_REQUEST['sf_search_txt']):""; $args = array( 'post_type' => 'attorneys', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => -1, 'suppress_filters' => true ); $my_args=[]; $acf_array=array( 'bio', 'position', 'location', 'attorney_last_name', 'attorney_first_name', 'principal_practice_areas', 'education', 'email', 'phone', 'other_phone_number', 'fax', 'address', 'other_address', 'attorney_vcard', 'experience', 'bar_admissions_certifications', 'professional_community', 'news', 'publications_presentations', 'pdf_photo', 'attorney_search_photo', '_attorney_social_media', '_hidden_relationship_title' ); if(!empty($selected_cat) && !empty($_sft_first_letter)){ $my_args[] = array( 'taxonomy' => 'first_letter', 'field' => 'slug', 'terms' => $_sft_first_letter, ); foreach($selected_cat as $key=> $lSlug){ $my_args[]=array( 'taxonomy' => 'location', 'field' => 'slug', 'terms' => "$lSlug", ); } $args['tax_query'] = array('relation' => 'AND',$my_args); }else if( !empty($selected_cat) && empty($_sft_first_letter)){ foreach($selected_cat as $key=> $lSlug){ $my_args[]=array( 'taxonomy' => 'location', 'field' => 'slug', 'terms' => "$lSlug", ); } $args['tax_query'] = array('relation' => 'AND',$my_args); }else if(empty($selected_cat) && !empty($_sft_first_letter)){ $my_args[] = array( 'taxonomy' => 'first_letter', 'field' => 'slug', 'terms' => $_sft_first_letter, ); $args['tax_query'] = array('relation' => 'AND',$my_args); } if(!empty($selected_txt)){ $acff =[]; $args['s'] = $selected_txt; $loop11 = new WP_Query($args); if($loop11->have_posts()){ $loop =$loop11; }else{ unset($args['s']); $args['meta_query']=array('relation' => 'OR'); foreach($acf_array as $key=>$kacf){ $args['meta_query'][] = array( 'key' => "$kacf", 'value' => $selected_txt, 'compare' => 'LIKE', ); } $loop = new WP_Query($args); } }else{ $loop = new WP_Query($args); } // if(isset($_GET['print'])){ // echo "
";
            // print_r($_REQUEST);
            // print_r($args);
            // echo "
"; // } $html = ""; $html .="
"; if($loop->have_posts()){ while ( $loop->have_posts() ) : $loop->the_post(); $post_id = get_the_id(); $title = get_post_field( 'post_title', $post_id ); $position = get_field( "position", $post_id ); $location = get_field( "location", $post_id ); $email = get_field( "email", $post_id ); $phone = get_field( "phone", $post_id ); $url = get_permalink($post_id); $attorney_vcard = get_field( "attorney_vcard", $post_id ); $attorney_search_photo = get_field( "attorney_search_photo", $post_id ); $html.= "
"; $html.= "
profile image
"; $html.= "
"; $html.= ""; $html.= "
".$position."
"; $html.= "

".implode( ', ', $location )."

"; $html.= ""; $html.= "
".$phone."
"; $html.= ""; $html.= "
"; $html.= "
"; endwhile; }else { $html.= 'No results found'; } $html.= "
"; wp_reset_query(); echo $html; die(); } add_action('wp_ajax_attorney_post_with_filter', 'attorney_post_with_filter'); add_action('wp_ajax_nopriv_attorney_post_with_filter', 'attorney_post_with_filter'); add_filter('acf/update_value/name=news', 'ayt_add_titles_to_post_for_search', 10, 3); function ayt_add_titles_to_post_for_search($value, $post_id, $field) { // use a new field, it does not need to be an acf field // first delete anything it might hold delete_post_meta($post_id, '_hidden_relationship_title'); if (!empty($value)) { $posts = $value; if (!is_array($posts)) { $posts = array($posts); } $_hidden_relationship_title=''; foreach ($posts as $post) { // add each related post's title // add_post_meta($post_id, '_hidden_relationship_title', get_the_title($post), false); $_hidden_relationship_title .=get_the_title($post); } add_post_meta($post_id, '_hidden_relationship_title', $_hidden_relationship_title, false); } return $value; }