Multiple meta query get high server load.
-
This is my code i have 50+ meta query. is there any option to optimize query.
global $wpdb; $requestData = $_GET['profile']; if(!empty($requestData)) { $meta_query = array('relation' => 'AND'); foreach ($requestData as $key => $value) { $meta_query[] = array( 'key' => $value, 'value' => '1', 'compare' => '=' ); } $args = array( 'post_type' => 'healthcare', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => $meta_query); $loop = new WP_Query( $args ); $total = $loop->found_posts; $post_ids = wp_list_pluck( $loop->posts, 'ID' ); $ids = implode(',', $post_ids); echo $total.'<input type="hidden" name="matchids" value="'.$ids.'" />'; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Multiple meta query get high server load.’ is closed to new replies.