wordpress meta value compare between two date

After some research on wp codex I found my solution. Here I have to change birth_date format during save. I saved value like yy-mm-dd this format and changed my meta_query Here is the code $studentdata = get_users( array( ‘meta_query’=> array( array( ‘key’ => ‘birth_date’, ‘value’ => array( $startyear.’-01-01′,$endyear.’-12-31′), ‘compare’ => ‘BETWEEN’, ) ), ‘role’=>’student’ ) … Read more

Find posts by related taxonomy field

You’re meta querying on serialized data. I mean the artist from ‘key’ => ‘artist’ is serialized. That’s why your meta query hasn’t work. So here is my possible solution- $projects = get_posts(array( ‘post_type’ => ‘project’, ‘meta_query’ => array( array( ‘key’ => ‘artist’, // name of custom field ‘value’ => ‘”%’ . $artist->term_id . ‘%”‘, ‘compare’ … Read more

Meta Query Based on Month Range

The problem is that you’re passing a meta VALUE in the key field of the meta_query…you should be passing your meta KEY there (“_wccf_pp_event_date”), as in: $seasons = array ( ‘spring’ => array (‘2017-03-21’, ‘2017-06-20’), ‘summer’ => array (‘2017-06-21’, ‘2017-09-20’), ‘fall’ => array (‘2017-09-21’, ‘2017-12-20’), ‘winter’ => array (‘2017-12-21’, ‘2018-03-20’), ) ; foreach ($seasons as … Read more

meta_query array in ‘values’ returns an error

LIKE as a compare value doesn’t make sense with an array. You want compare to be IN. Also, you’ve got an extra set of quotes in the values for no reason: $meta_query_args = [ [ ‘key’ => ‘checkboxes’, ‘value’ => [‘facebook’, ‘twitter’], ‘compare’ => ‘IN’, ], ]; EDIT: So, according to your comment you’re using … Read more

meta query or with meta value

‘meta_key’ => ‘clpr_topcoupon’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ You can solve the problem by using order by clause then there will no need to write meta query. Please use the above code to solve your problem.It will show the posts according to descending order of the value in meta key.

Extend meta query arguments

Try this $args = array( ‘post_type’ => ‘events’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘fl_type’, ‘value’ => ‘Awards’ ), array( ‘key’ => ‘fl_expire’, ‘value’ => 0, ‘type’ => ‘NUMERIC’, ), array( ‘key’ => ‘fl_global’, ‘value’ => 1, ‘type’ => ‘NUMERIC’, ), ), ‘posts_per_page’ => -1, ‘meta_key’ => ‘fl_order’, ‘orderby’ => ‘meta_value_num’, ‘order’ … Read more

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