Skip Navigation

[Resolved] Order and OrderBy in Toolset Views

This thread is resolved. Here is a description of the problem and solution.

Problem:
What's the difference of "order" and "orderby" in Toolset Views?

Solution:
The "order" Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'ASC'.

So you can say, "orderby" the ID of the post, "order" Descendant.

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 6 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#619214

I am trying to: sort the users in a particular sort order as for example array(98,95,99,102) and orderby => include. So that users in a view comes in a loop starting from 98 then 95 and 99 and lastly 102 and so on.

This is my code
add_filter( 'wpv_filter_user_query', 'sort_by_lastname_func', 100, 3 );

function sort_by_lastname_func( $query_args, $view_settings, $view_id ) {
if ($view_id == 9359 ) {

$query_args['include'] = array(98,95,99,102);
$query_args['orderby'] = 'include';

}
return $query_args;
}

Instead, I got: It is sorting right now by 95,98,99,102 as ASC default order but it should sort by include parameter as supported by WordPress.

Check this screenshot: hidden link
Link to wordpress documentation is: https://codex.wordpress.org/Function_Reference/get_users

#619357

orderby and order are not the same as far I know.

You can very well orderby "include", as your experiment shows, but the order is never orderby, that is a different attribute that actually orders the orderby:
https://codex.wordpress.org/Class_Reference/WP_User_Query > Order & Orderby Parameters

So you always have an order (as or desc).
No matter what you orderby.
The order Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'ASC'.
And orderby in your case is an array of ID's, so it will order them - but not by them.

I would not say this is a Tooslet Bug, but a WordPress limitation.

Can you confirm?

#619372

Hello Beda,

If you study the documentation of WordPress closely, when we orderby include, then ordering should be by the include ids listed in the array.

After trying so many things, i was able to make it work by including the order argument as neither ASC or DESC but as none.

Then the ordering by was by include ids.

I am not sure whether it is a bug in Toolset or WordPress, but still as per documentation it didnt worked out. It was just i tried order as none and it worked and nothing listed like this in wordpress documentation.

This is my general feedback as i already have it solved.

Thanks

#619375

This is not a BUG, it is exactly as I understand it to work

One is orderby (a set of values to order by) and the other is the order, to order those orderby items: Asc, Desc.

This is not just skipped.
You cannot "order" by an array of values, but only by a logic of ordering or none (hence respecting the initial sequence, no ordering at all).

I suggest to feedback or edit the WordPress Documentation if you feel it is not clear.

We do not make it, it's a volunteers and Automattics' effort:
https://codex.wordpress.org/