Skip Navigation

[Resolved] Default table sort

This support ticket is created 6 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 6 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1120705

So i got this table that is listing members.

The table is initally sorted by post title in ascending order (set from Order by in top of the view settings page).

So i used Loop Wizard to create a table and added sort to it.

Now when you load the page and click the post title because you want to sort it, it will start to sort ascending.. the view is already ascending, i need to sort it descending on first click.

I tried adding order="DESC" as an argument to the table header in the view

[wpv-heading name="post-title" order="DESC"]post title[/wpv-heading]

but it ignores this.

I see that the data-order in the output is set to asc. How do i change this to desc?

Debug info is not relevant in this case. Nor is access to the site required.
It's a simple question about usage, and not a site-specific question.

Thank you in advance

#1121346

Hi Thomas,

Thank you for contacting us and I'll be happy to assist.

I'm afraid, there is no direct shortcode or filter available to change the default sorting order (front-end) to "DESC", but this can be achieved using a custom script.

1. First, please update your post title shortcode, to include a special class "fieldforsort":


[wpv-heading name="post-title" class="fieldforsort"]Post title[/wpv-heading]

2. Next, you can add the following script in "JS editor" tab under the "Loop Editor":


// function to get parameter from URL
function GetURLParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++)
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam)
        {
            return sParameterName[1];
        }
    }
}

// function to update the default "data-order"
$(document).ready(function () {
   var sort_order = GetURLParameter('wpv_sort_order');
    if(typeof sort_order === 'undefined') {
   	 $('a.fieldforsort').attr('data-order', 'desc');
    }
});

I hope this helps! Please let us know how it goes and if you need any further assistance.

regards,
Waqar