empty (All) > custom_directory (only if exactly one) // Only auto-select directory if there's exactly ONE directory in custom_directory $directory_type = ! empty( $_GET['directory_type'] ?? '' ) ? $_GET['directory_type'] : ( ( ! empty( $custom_directory ) && count( $custom_directory ) === 1 ) ? ( $custom_directory[0] ?? '' ) : '' ); // Initialize taxonomy variables $adqs_cat_terms = []; $adqs_location_terms = []; $adqs_tags = []; // Taxonomies are now static and shared across all post types $category_taxonomy = 'adqs_category'; $location_taxonomy = 'adqs_location'; $tags_taxonomy = 'adqs_tags'; // Load terms for each taxonomy - filter by directory if custom_directory is specified if ( ! empty( $custom_directory ) && is_array( $custom_directory ) ) { // Get post types for selected directories $directory_post_types = []; foreach ( $custom_directory as $dir_slug ) { $post_type = adqs_get_post_type_by_directory( $dir_slug ); if ( ! empty( $post_type ) && post_type_exists( $post_type ) ) { $directory_post_types[] = $post_type; } } if ( ! empty( $directory_post_types ) ) { // Query posts to find which terms are actually used $posts_query = new WP_Query( [ 'post_type' => $directory_post_types, 'posts_per_page' => -1, 'fields' => 'ids', 'post_status' => 'publish', ] ); if ( $posts_query->have_posts() ) { // Get category terms if ( taxonomy_exists( $category_taxonomy ) ) { $cat_term_ids = []; foreach ( $posts_query->posts as $post_id ) { $post_cats = wp_get_post_terms( $post_id, $category_taxonomy, [ 'fields' => 'ids' ] ); if ( ! is_wp_error( $post_cats ) && ! empty( $post_cats ) ) { $cat_term_ids = array_merge( $cat_term_ids, $post_cats ); } } $cat_term_ids = array_unique( $cat_term_ids ); if ( ! empty( $cat_term_ids ) ) { $adqs_cat_terms = get_terms( [ 'taxonomy' => $category_taxonomy, 'hide_empty' => true, 'include' => $cat_term_ids, ] ); } } // Get location terms if ( taxonomy_exists( $location_taxonomy ) ) { $loc_term_ids = []; foreach ( $posts_query->posts as $post_id ) { $post_locs = wp_get_post_terms( $post_id, $location_taxonomy, [ 'fields' => 'ids' ] ); if ( ! is_wp_error( $post_locs ) && ! empty( $post_locs ) ) { $loc_term_ids = array_merge( $loc_term_ids, $post_locs ); } } $loc_term_ids = array_unique( $loc_term_ids ); if ( ! empty( $loc_term_ids ) ) { $adqs_location_terms = get_terms( [ 'taxonomy' => $location_taxonomy, 'hide_empty' => true, 'include' => $loc_term_ids, ] ); } } // Get tag terms if ( taxonomy_exists( $tags_taxonomy ) ) { $tag_term_ids = []; foreach ( $posts_query->posts as $post_id ) { $post_tags = wp_get_post_terms( $post_id, $tags_taxonomy, [ 'fields' => 'ids' ] ); if ( ! is_wp_error( $post_tags ) && ! empty( $post_tags ) ) { $tag_term_ids = array_merge( $tag_term_ids, $post_tags ); } } $tag_term_ids = array_unique( $tag_term_ids ); if ( ! empty( $tag_term_ids ) ) { $adqs_tags = get_terms( [ 'taxonomy' => $tags_taxonomy, 'hide_empty' => true, 'include' => $tag_term_ids, 'hierarchical' => false, ] ); } } } wp_reset_postdata(); } } else { // No custom_directory specified, load all terms if ( taxonomy_exists( $category_taxonomy ) ) { $adqs_cat_terms = adqs_get_terms( $category_taxonomy ); } if ( taxonomy_exists( $location_taxonomy ) ) { $adqs_location_terms = adqs_get_terms( $location_taxonomy ); } if ( taxonomy_exists( $tags_taxonomy ) ) { $adqs_tags = adqs_get_terms( $tags_taxonomy, [ 'hierarchical' => false ] ); } } $current_url = $wp->request; // all request data $search = isset( $_GET['ls'] ) ? $_GET['ls'] : ''; $category = isset( $_GET['categories'] ) ? $_GET['categories'] : ''; $location = isset( $_GET['locations'] ) ? $_GET['locations'] : ''; $tags = ( isset( $_GET['tags'] ) && ! empty( $_GET['tags'] ) ) ? explode( ',', $_GET['tags'] ) : []; $minprice = isset( $_GET['minPrice'] ) ? $_GET['minPrice'] : ''; $maxprice = isset( $_GET['maxPrice'] ) ? $_GET['maxPrice'] : ''; $rangePrice = isset( $_GET['rangePrice'] ) ? $_GET['rangePrice'] : ''; $rating = isset( $_GET['rating'] ) ? $_GET['rating'] : ''; $display_listings = isset( $_GET['display_listings'] ) ? $_GET['display_listings'] : ''; // exclude search field $excludedFilterFields = ! empty( adqs_get_setting_option( 'excludedFilterFields' ) ) ? adqs_get_setting_option( 'excludedFilterFields' ) : []; // Get style type $style_type = $args['style_type'] ?? ''; ?>
">

$filter_directories ] ); ?>
$filter_directories ] ); ?>