Searching user meta using WP_User_Query

Try this: $yoursearchquery = ‘This is my search’; $users = new WP_User_Query(array( ‘search’ => $yoursearchquery, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘shoe_size’, ‘value’ => $yoursearchquery, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘shoe_color’, ‘value’ => $search_operation, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘shoe_maker’, ‘value’ => $yoursearchquery, ‘compare’ => ‘=’ ) ) … Read more

SQL Statement generated by WP_Query not producing expected results

It looks like this section: AND (wptom_posts.post_status=”publish” OR wptom_posts.post_author = 1 AND wptom_posts.post_status=”private”) is not tied in at all to the two different query conditions… Perhaps the original code should be three conditions for part 1: array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘operator’ => ‘IN’), array( ‘taxonomy’ => ‘post_tag’, ‘field’ … Read more

How to support multiple search terms query within one process?

Fixed: Search and result the all keys; <?php $the_keys = preg_split(‘/\s+/’, str_replace(‘-‘,’ ‘,get_query_var(‘s’)),-1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $total_keys = count($the_keys); $the_query = new WP_Query(array(‘post_type’=>’nothing’)); if($total_keys>1){ for($i = 0; $i<=$total_keys; $i++) { $the_query_mask = new WP_Query(array(‘s’ => $the_keys[$i])); $the_query->post_count = count( $the_query->posts ); $the_query->posts = array_merge( $the_query->posts, $the_query_mask->posts ); } } else { $the_query= new WP_Query(array(‘s’ => … Read more

WP_Query: How do I sort on meta value and use LEFT JOIN?

WordPress is also provide more filters to change custom queries. https://codex.wordpress.org/Custom_Queries add_filter(‘posts_join’, ‘custom_query_join’ ); $premium = new WP_Query( $premium_args); remove_filter(‘posts_join’, ‘custom_query_join’ ); // remove filter bcz not effect to another query to use after this query. function custom_query_join( $join ){ $join .= ‘Put here join to table’; return $join; }

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