Optimize WP Meta Query for large amount of post meta?
Ok, Ive found that ‘compare’ => ‘!=’ slows it down, but ‘compare’ => ‘<>’ does not. I guess both are the same, so I guess this question is solved.
Ok, Ive found that ‘compare’ => ‘!=’ slows it down, but ‘compare’ => ‘<>’ does not. I guess both are the same, so I guess this question is solved.
Problem was that I had a plugin installed that deals with the searches, it’s called Better Search. function query_1($query){ $query .= “,wp_postmeta.meta_value as total_saless “; return $query; } add_filter( ‘bsearch_posts_match_field’, ‘query_1′ ); function query_2($query){ $query .= “AND wp_postmeta.meta_key=’total_sales’ “; return $query; } add_filter( ‘bsearch_posts_where’, ‘query_2’ ); function query_3($query){ $query = ” CAST(total_saless AS INTEGER) > … Read more
you can create conditionnal arguments like that : $user_args = [ ‘orderby’ => ‘display_name’, ‘order’ => ‘asc’, ‘meta_query’ => array( array( ‘key’ => ‘verifier_assign_country’, ‘value’ => $countryCode, ‘compare’ => ‘=’ ), ) ]; if (“” !== $univCode) { $user_args[“meta_query”][] = array( ‘key’ => ‘verifier_assign_univ’, ‘value’ => $univCode, ‘compare’ => ‘LIKE’ ); } $users = get_users($user_args);
OK, so a little bit of guessing is involved in that answer, since you’ve posted only parts of your code, but… I assume that your code looks like that: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘post_category’ => array(14,16,19) ); $posts = get_posts($args); foreach ( $posts as $post ) { … Read more
When working with a post, almost all wp_postmeta are deleted
It’s a little bit off-topic, but nevertheless… Let’s say you want to change first range_cost to 5.789 and third to 6.890 for product 148. Here’s the code: $product_attr = get_post_meta( 148 , ‘redq_day_ranges_cost’); $product_attr[0][0][‘range_cost’] = 5.789; $product_attr[0][2][‘range_cost’] = 6.890; update_post_meta(148, ‘redq_day_ranges_cost’, $product_attr);
Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
Check value of post meta within IF statement
Remove item from post_meta array via AJAX
Maybe the problem could be that you dont show properly the value of the custom field, try this: echo ‘<textarea rows=”5″ cols=”220″ name=”custom_product_input” id=”custom_product_input”>’ . $text . ‘</textarea>’;