Ordering Subcategories

I have never used the plugin you found but it looks pretty heavy, at least on the backend, and may be overkill unless you need a lot more functionality than described in the question. get_categories operates from cached data so my thought was to simple alter the returned array rather than perform another query or … Read more

Changing posts order on a page

posts, in descending order by the title: this is a format of post order by it’s title to add title query_posts( array( ‘category__and’ => array(1,3), ‘posts_per_page’ => 2, ‘orderby’ => ‘title’, ‘order’ => ‘DESC’ ) ); And it’s your code want change global $post; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(array( ‘post_type’ => ‘staff-page’, … Read more

Want to order by Meta Values (tweaking Post Order Widget)

Because price is not a post table column (I’m assuming it’s a post meta field), you need to extend the query & order by meta_value_num instead: case ‘title’: if ( ! $meta_query = $vars->get( ‘meta_query’ ) ) $meta_query = array(); $meta_query[] = array( ‘compare’ => ‘!=’, ‘value’ => ”, ‘key’ => ‘price’, /* This should … Read more

How to order custom user list columns by datetime?

I think you could simplify this a lot by using the pre_get_users hook, instead of working directly with the complicated SQL within the pre_user_query hook. Try something like: add_action( ‘pre_get_users’, function( \WP_User_Query $q ) { $qv = &$q->query_vars; if( isset( $qv[‘orderby’] ) && ‘test_date’ === $qv[‘orderby’] ) { // Custom meta query $qv[‘meta_query’] = [ … Read more

Sort posts by meta value with get method

You’re not actually using the $_GET[‘orderby’]-value anywhere. What you’re doing in your code is ordering by the text_date-meta value, always. If you want to order by date by default, and when $_GET[‘orderby’] is set to default orderby-values or if $_GET[‘orderby_meta’] is set, order by those instead you need to do something like this: if (isset($_GET[‘orderby’]){ … Read more