How to Compare Two Meta Fields

A rought method would be to set value of balance to ‘mt1.meta_value’ and then use a ‘posts_request’ filter to remove the escaping quotes: $args = array( ‘post_type’ => ‘post’, // maybe not ‘meta_query’ => array( array( ‘key’ => ‘balance’, ‘compare’ => ‘>=’, ‘value’ => ‘mt1.meta_value’, // this will be treated as a string ‘type’ => … Read more

Add custom fields to search

please never do this: ‘value’ => $_GET[‘s’] … $query->get(‘s’);, get_search_query, or sanitize_key($_GET[‘s’]) are all safer options. Technically we shouldn’t be using get-params in wordpress at all, it’s not a best-practice. That get value could be all sorts of bad things, & we don’t want to pass it along to the db without making sure it’s … Read more

Get posts based on meta key/value

The problem It looks like you are saving the data as: $a = array( “13112” ); update_post_meta( $post_id, “article_author”, $a); where this will give you the meta_value a:1:{i:0;s:5:”13112″;} Your first query will give you escaped quotes: LIKE ‘%\”13112\”%’ Method 1 If you save the author array with numbers instead: $a = array( 13112 ); update_post_meta( … Read more

Get result from meta_query() between two numbers

Multiple meta values can be compared with BETWEEN with an array value: ‘meta_query’ => array( array( ‘key’ => REALIA_PROPERTY_PREFIX .’attributes_area’, ‘value’ => array( $first_val, $second_val ), ‘type’ => ‘numeric’, ‘compare’ => ‘BETWEEN’, ), // inner array. ), // outer array. You can see this in Developer Doc.

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