SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)

Solved. After the edit it was easy. It is allowed to use type => ‘decimal(x,x)’ in meta_query. Maximum precision is decimal(65,30). https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html array(6) { [“orderby”]=> array(2) { [“uss_product_price”]=> string(4) “DESC” [“title”]=> string(3) “ASC” } [“meta_query”]=> array(3) { [“relation”]=> string(3) “AND” [“sortprimary_clause”]=> array(3) { [“key”]=> string(17) “price” [“compare”]=> string(6) “EXISTS” [“type”]=> string(13) “decimal(30,5)” } [0]=> array(4) … Read more

WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field

The reason you’re only getting those users that have that meta_key is because you’re include ‘meta_key’ => ‘…’ in $args. That limits results to those that have that key, regardless of any clauses you may have in a meta_query. This applies to WP_Query, WP_User_Query and WP_Comment_Query. Starting in WP 4.2, you can “name” the clauses … Read more

How to do meta_query for attachments?

I went with custom taxonomy instead of custom meta field and it works great (although I am still not sure why meta_query didn’t work) I have saved custom taxonomy term for each attachment wp_set_object_terms($post->ID, $slug, ‘image_category’ ); And custom query args are $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => 44, ‘post_status’ => ‘inherit’, ‘post_parent’ … Read more

WP_Query: include custom post type only with specific meta value

If the key-2 is uniquely assigned to cpt-3 post type, then you can add another meta query argument to your query arguments: array( ‘key’ => ‘key-2’, ‘value’ => 1, ‘compare’ => ‘=’ ) If not, you can run another query, and then merge them as follows: $final_query = array_merge( (array) $query_1, (array) $query_2 ); But, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)