meta_query all posts between to ages

you can write like for this. ‘meta_query’ => array( array( ‘key’ => ‘_age_from’, ‘value’ => sanitize_text_field( $_REQUEST[‘age_from’] ), ‘compare’ => ‘>=’, ‘type’ => ‘NUMERIC’ ), array( ‘key’ => ‘_age_to’, ‘value’ => sanitize_text_field( $_REQUEST[‘age_to’] ), ‘compare’ => ‘<=’, ‘type’ => ‘NUMERIC’ ) );

User Relationship

if I were you, I would use the wp_usermeta table. it is possible to add information to this table easily: add_user_meta(NEW_USER_ID, “PARENT_USER_ID”,USER_ID,true); USER_ID: the Id of top level user, (In your case id of user A) “PARENT_USER_ID”: some key that you could search and find result based on NEW_USER_ID: The Id of sub_user true: To … Read more

How to exlude posts that have certain meta_value?

WordPress 3.5 and up supports EXISTS and NOT EXISTS comparison operators. compare (string) – Operator to test. Possible values are ‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘LIKE’, ‘NOT LIKE’, ‘IN’, ‘NOT IN’, ‘BETWEEN’, ‘NOT BETWEEN’, ‘EXISTS’ (only in WP >= 3.5), and ‘NOT EXISTS’ (also only in WP >= 3.5). Default value is ‘=’. http://codex.wordpress.org/Class_Reference/WP_Query … Read more

How to use meta_query to check if a meta field has something set?

I figured it out, meta_query must be an array within an array as it is intended for advanced queries using ‘relation’. meta_query => array ( array ( //’relation’ => ‘OR’, ‘key’ => ‘audio_file’, //The field to check. ‘value’ => ”, //The value of the field. ‘compare’ => ‘!=’, //Conditional statement used on the value. ), … Read more

Very slow query with meta_query on large database

It is recommended to stick with WP_query for grabbing WordPress posts; but, you can build your own queries directly from the postmeta table, then iterate through the results. Depending on the query, this may be faster (Not often; WordPress works hard to make their database queries as fast as they can be). global $wpdb; $table … Read more

meta_query problem

Meta queries aren’t intended for filtering which posts are returned. You can use them this way, but the database isn’t optimised for it. There are few things worse for scaling and performance than meta queries: Remote requests to other servers Modifying and rescaling images Queruing for what you don’t want ( e.g. show me all … Read more

WP_User_Query with meta_query array relation ‘OR’

From the Codex: Multiple custom user fields handling $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, 0 => array( ‘key’ => ‘country’, ‘value’ => ‘Israel’, ‘compare’ => ‘=’ ), 1 => array( ‘key’ => ‘age’, ‘value’ => array( 20, 30 ), ‘type’ => ‘numeric’, ‘compare’ => ‘BETWEEN’ ) ) ); Try adding the 0 … Read more

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