Skip Navigation

[Resolved] Sorting within filters

This support ticket is created 3 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by Purchasing WCER 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2174383

Tell us what you are trying to do? I would like the CESA filter to sort ascending. Right now, it doesn't seem to recognize that 10 shouldn't come after 1 and before 2.

What is the link to your site? hidden link

#2174907

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand, you have added the post relationship filter to your view and now you want to display the post relationship filter select box value in ASC order. If this is correct :

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2175955

Minesh
Supporter

Languages: English (English )

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

Unfortunately - the admin access details you shared is not working at this end. Can you please send me working admin access details.

I have set the next reply to private which means only you and I have access to it.

#2177063

Minesh
Supporter

Languages: English (English )

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

Ok - the thing is that the post is already order by post title and post title is a string. As post title treated as string the numbers in post title string will also be treated as string. As post title is a string itself.

We can not do much here.

#2177379

Hi Minesh,

Okay. I can think of 2 other ways we might accomplish this. The first is to sort by slug rather than title. That way we can add a zero in front of the single digit numbers in the slugs so they will sort properly. I tried this code (found in a Toolset support ticket) but it doesn't work. Are you able to help with this?

//Order search results by slug
add_filter('wpv_filter_query', 'post_ordered_by_slug', 99);

function post_ordered_by_slug( $query_args ){

$query_args ['orderby'] = 'name';

return $query_args;
}

If that won't work, the CESA information is also stored on the district as a custom field and maybe you could help me to use that as a filter rather than the CESA post type?

Thank you!

#2177399

Minesh
Supporter

Languages: English (English )

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

The thing is that you can only sort the post relationship filter based on the available options given with the filter when you add the filter: hidden link

There is no extremal way to filer the post relationship filter.

#2177419

Would it be possible to do this using JavaScript?

#2178379

Minesh
Supporter

Languages: English (English )

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

There is no workaround available as of now. It could be possible but then there is also possibility that it could break the core select 2 functionality and to offer support for such custom code is beyond the scope of our support policy.

If you need custom programming for your project, you're welcome to contact and get help from any of our certified partners:
=> https://toolset.com/contractors/

#2178647

I figured out a work-around. Please consider adding order by slug as an option.