[ [ 'key' => 'account_status', 'value' => ['approved', 'active', 'inactive'], 'compare' => 'IN' ] ], 'fields' => 'ID' ]); $approved_user_ids = $user_query->get_results(); if (!empty($approved_user_ids)) { // Query trainer profiles for approved users only $args = [ 'post_type' => 'trainer_profile', 'posts_per_page' => 12, 'post_status' => 'publish', 'meta_query' => [ 'relation' => 'AND', [ 'key' => 'is_public_profile', 'value' => '1', 'compare' => '=' ], [ 'key' => 'user_id', 'value' => $approved_user_ids, 'compare' => 'IN' ] ] ]; $query = new WP_Query($args); $total_pages = $query->max_num_pages; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $profile_id = get_the_ID(); $user_id = get_post_meta($profile_id, 'user_id', true); // Get real event count for this trainer $event_count = 0; if ($user_id && function_exists('tribe_get_events')) { $events = tribe_get_events([ 'author' => $user_id, 'eventDisplay' => 'all', 'posts_per_page' => -1, 'fields' => 'ids' ]); $event_count = count($events); } $trainers[] = [ 'profile_id' => $profile_id, 'user_id' => $user_id, 'name' => get_post_meta($profile_id, 'trainer_display_name', true), 'city' => get_post_meta($profile_id, 'trainer_city', true), 'state' => get_post_meta($profile_id, 'trainer_state', true), 'certification' => get_post_meta($profile_id, 'certification_type', true), 'profile_image' => get_post_meta($profile_id, 'profile_image_url', true), 'event_count' => $event_count ]; } } wp_reset_postdata(); // Sort trainers: Certified measureQuick Trainers first, Champions last usort($trainers, function($a, $b) { $a_cert = $a['certification']; $b_cert = $b['certification']; // Define sort order: Trainers = 1, Champions = 2, Others = 3 $a_priority = 3; // Default for others $b_priority = 3; // Default for others if ($a_cert === 'Certified measureQuick Trainer') { $a_priority = 1; } elseif ($a_cert === 'Certified measureQuick Champion') { $a_priority = 2; } if ($b_cert === 'Certified measureQuick Trainer') { $b_priority = 1; } elseif ($b_cert === 'Certified measureQuick Champion') { $b_priority = 2; } // Primary sort by certification priority if ($a_priority !== $b_priority) { return $a_priority - $b_priority; } // Secondary sort by name (alphabetical) return strcasecmp($a['name'], $b['name']); }); } // Enqueue required scripts and styles wp_enqueue_style('hvac-find-trainer', HVAC_PLUGIN_URL . 'assets/css/find-trainer.css', [], HVAC_VERSION); wp_enqueue_script('hvac-find-trainer', HVAC_PLUGIN_URL . 'assets/js/find-trainer.js', ['jquery'], HVAC_VERSION, true); wp_enqueue_style('dashicons'); // Localize script with necessary data wp_localize_script('hvac-find-trainer', 'hvac_find_trainer', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('hvac_find_trainer'), 'map_id' => '5872', 'messages' => [ 'loading' => __('Loading...', 'hvac'), 'error' => __('An error occurred. Please try again.', 'hvac'), 'no_results' => __('No trainers found matching your criteria.', 'hvac'), 'form_error' => __('Please check the form and try again.', 'hvac'), 'form_success' => __('Your message has been sent! Check your inbox for more details.', 'hvac') ] ]); ?>
Find certified HVAC trainers in your area. Use the interactive map and filters below to discover trainers who match your specific needs. Click on any trainer to view their profile and contact them directly.
Map plugin not installed
Are you an HVAC Trainer that wants to be listed in our directory?
Become A Trainer