Skip Navigation

[Fermé] Sort view by page order

This support ticket is created Il y a 7 années et 2 mois. 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.

Marqué : 

This topic contains 7 réponses, has 2 voix.

Last updated by Minesh Il y a 7 années et 2 mois.

Assigned support staff: Minesh.



I want to sort a view by the wordpress page order, I'm using this plugin to set the post order easily in wp admin - but how do I get views to reflect it?




Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

With views, you can order your posts with custom fields, you can check if the custom field that maintain the order using your plugin, is that custom field is available when you edit your views under "Ordering" section drop-down.

if it’s not available there, perhaps it’s a custom field, you can bring custom field under Types control from:
=> Types => Custom field control

Once your custom field is successfully imported to Types, you can check the "Ordering" drop-down for same field and set "order by", your custom field.


You may use "wpv_filter_query" hook.

This are the ways you may able to set your post order. Otherwise you may contact your plugin author to help on this.



It has sort by menu order which I would have thought would work - but it just ignores it. That plugin just uses the default wordpress 'order' attribute.



We had a filter overriding it, working nicely now but - i need a better way of determining which view is being used, on some pages we have nested views, which may be ordered differently.

How do I detect the view ID being used?

add_filter('posts_orderby', 'my_client_order', 98, 2);

function my_client_order($order, $q) {
if (!empty($_GET["wpv-sort"])) {
$sort = $_GET["wpv-sort"];

if ($sort == 'alpha-asc') {
return 'post_title ASC';

if ($sort == 'alpha-desc') {
return 'post_title DESC';
//Support from wp-types:
if ($sort == 'date-asc') {
return 'post_date ASC';

if ($sort == 'date-desc') {
return 'post_date DESC';
} else {

//return 'post_date DESC';
return 'menu_order DESC';



Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please try to use global variable $WP_Views.

For example:

global $WP_Views;
 if($WP_Views->current_view == 1234){
//do something you want

Will try that, how does that work with nested views or multiple views on a page?


Ok that's working nicely, now I just need to add in the option to turn this on and off - what's the best way?

- Add a new checkbox to the page where the view is inserted, check if this is checked
- Use a shortcode attribute on the view

How can I check a types field value on the page where the view is insert from within the above code?




Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to hear that your original issue is fixed.

As the original issue is resolved may I kindly ask you please to open a new ticket for your new question and mark this thread as resolved. This will also help other users with similar problems find solutions when searching the forum.

Thank you for understanding.

Le sujet ‘[Fermé] Sort view by page order’ est fermé à de nouvelles réponses.