wp query by search in titles only & put the posts in loop

If you want to limit the filter from this answer (add that function to your plugin or your theme’s functions.php) just to one query, remove the filter when you are done: add_filter( ‘posts_search’, ‘__search_by_title_only’, 500, 2 ); $query = new WP_Query( array( ‘s’ => ‘mykeyword myotherkeyword’, ‘cat’ => array( 22, 32 ), ‘orders’ => ‘DESC’, … Read more

Sort users by meta_value_num

Add this code in functions.php. Use orderby with meta_value_num and define meta_key in argument array. add_action( ‘pre_user_query’, ‘wps_pre_user_query’ ); function wps_pre_user_query( &$query ) { global $wpdb; if ( isset( $query->query_vars[‘orderby’] ) && ‘meta_value_num’ == $query->query_vars[‘orderby’] ) $query->query_orderby = str_replace( ‘user_login’, “$wpdb->usermeta.meta_value+0”, $query->query_orderby ); }

Does using a custom query_var create a security hole?

Regardless of whether you registered new_var as a query_var, all GPC data (GET, POST, COOKIE) should be considered tainted. Basically, this data is user input. This means that you will need to clean and validate the data anyway. Common cleaning methods include casting the variable to a certain type (like integer or string), using a … Read more