Skip Navigation

[Resolved] Ignoring "the" / "a" when Sorting by Post Title

This support ticket is created 6 years, 7 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.

This topic contains 2 replies, has 2 voices.

Last updated by Thomas AMX 6 years, 7 months ago.

Author
Posts
#905999

Hi guys,

I wonder if there is an elegant way to omit articles such as "the" or "a" when sorting posts by post title in a view?

If we sort in ascending order, the default behaviour is:

1. Portugal
2. Spain
3. The Netherlands

However, in real-life situations, the desired order would usually be:

1. The Netherlands
2. Portugal
3. Spain

I know, setting up a custom field for the purpose of ordering is an option, but it is not very elegant and would require editing this field for every post.

Is there some trick to ignore "the" or "a" when sorting by title?

Cheers
Tom

#906101

There is no such native option, as the search is supposed to return the exact matching values, not some occurrences in randomly chosen strings parts.

To define what word to exclude, and at what position in the string would add lots of query time to the ordering, and not be easy to set as a GUI either.

This is not possible with any search plugin I know.
(Unless you use workarounds as you mention)

#906547

Thanks Beda. I have figured out I can sort by slug and simply not use "THE" in slugs.

Unlike taxonomy views, post views don't offer sorting by slug for some reason.

So, I adapted this solution:
https://toolset.com/forums/topic/allow-for-order-by-slug-for-post-types-view-continued/

I wish it was possible to sort by slug in the GUI, though.

Cheers
Tom