Multiple Values stored as array in Meta Query

An IN query is not a string comparison query. It is more like a bunch of OR statements. … WHERE tablename.animal IN (‘cat’,’dog’,’ferret’) is going to be the same as …WHERE tablename.animal=”cat” OR tablename.animal=”dog” OR tablename.animal=”ferret” $_POST[‘_casestudypost’] is going to be an array, and if you stored it as a single value in postmeta it … Read more

How to get user_meta value for new user regsitered?

Read de Codex entry for user_register action, it says: Not all user meta data has been stored in the database when this action is triggered. Note that doing: $user = wp_insert_user( $userdata ); update_user_meta( $user, ‘companyId’, 350 ); Follow this sequence: insert user -> run user_register action -> rung your update user meta function. So, … Read more

Building a scalable WordPress favouriting plugin – one serialised meta value array or many meta records

You forgot option 3 – Add a special table in which the pair (user,post id) will be the index. Ok I am not a MySQL person so maybe it is too extreme, but maybe having two tables one with users as index and one with posts will be even better. The thing about performance is … Read more

How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?

take a look at the reference docs for the WP_Query class: http://codex.wordpress.org/Class_Reference/WP_Query something like this: $args = array( //some key/value pairs…whatever ‘meta_query => array( array( ‘key’ => somekey, ‘value’ => somevalue, ‘compare’ => some comparison operator ), array( ‘key’ => some other key, ‘value’ => some other value, ‘compare’ => some comparison operator ) ) … Read more

Custom WP_Comment_Query with pagination and orderby?

The goal was to paginate comments, showing comments with the highest comment_rating meta value first. Thanks to the answer of cjbj and the comments by Milo and birgire I figured out the rather unintuitive solution to the issue. By using numberand offset I was able to make the results in the proper order, but pagination … Read more

Is it possible to orderby multiple meta_keys when using meta_value_num?

You might want to check out the query improvements in WP 4.2 for ‘orderby’ and ‘meta_query’. Details are on https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query. Try to name your meta_query clauses, then order by them. Following code is untested: $query = array( ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘cat1-clause’ => array( ‘key’ => ‘cat1’, ‘type’ => ‘numeric’ … Read more