How to create dynamic value in WP_Query meta_query

You should be able to do what you’re trying to do. I think the issue may be that relation should not be contained in it’s own array. It should look like this: $prodPost = new WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 6, ‘paged’ => 1, ‘meta_query’ => array( array( ‘relation’ => ‘AND’, array( ‘key’ … Read more

How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?

Looking at WP_Tax_Query and WP_Meta_Query used by Wp_Query, they return their respective where clauses with an AND relation, and no hook or $args to change that behavior. Furthermore, the tax_query is computed before the rest of the main query so that it’s included in the main query in term_taxonomy_id IN (…) form. Also the WP_Tax_Query … Read more

WordPress meta_query >= &

Looks like I found the solution. I needed to use compare instead of operator in the meta_query so array( ‘key’ => ‘vacancy_small_salary’, ‘value’ => $vacancy_small_salary, ‘operator’ => ‘>=’, ‘type’ => ‘NUMERIC’ ), becomes array( ‘key’ => ‘vacancy_small_salary’, ‘value’ => $vacancy_small_salary, ‘compare’ => ‘>=’, ‘type’ => ‘NUMERIC’ ), and the same for the other query

WP_Query: apply an SQL function to meta fileld value

You can use the filter posts_orderby. For a simple example: add_filter(‘posts_orderby’, ‘apply_sql_on_order’, 10, 2 ); function apply_sql_on_order($orderby, $query) { if(is_array($query->query_vars[“orderby”]) && array_key_exists(“apply_sql”, $query->query_vars[“orderby”])) { $orderby = preg_replace(“/(.*) (ASC|DESC)/”, $query->query_vars[“orderby”][“apply_sql”] . “($1) $2”, $orderby); } return $orderby; } $query = new WP_Query( array( ‘meta_query’ => array( ‘state_clause’ => array( ‘key’ => ‘state’ ), ), ‘orderby’ => … Read more

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