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

Order by the results of a function with WP_query

@JasCav Here is something to put you in the right direction. Maybe someone can edit where needed. // args $args = [ ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => 8, ‘paged’ => get_query_var( ‘paged’ ), ‘meta_key’ => ‘team_school’, ‘meta_value’ => $school_type, ‘orderby’ => ‘wpse_last_word’, //<– make filter for ordering! ‘order’ => ‘ASC’ ]; // … Read more

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