Skip Navigation

[Resolved] Display CPT by first letter

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.

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 2 replies, has 2 voices.

Last updated by Ben 6 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1122008

Ben

I have a CPT of Countries. I want to be able to list all these in one place but have the option to sort by the letter the country name starts with.

For example, at the top of the page I would like A,B,C,-Z. When you click on U, all the Countries that start with U are displayed.

Is there a way of doing this? I can't seem to find any sort of option in Views.

#1122564

Hi Ben,

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

To show your Countries with alphabetical filter, you can create a new custom taxonomy (e.g. "Alphabets") and add a term for each letter (i.e. A, B, C, - Z).

After that, you'll be able to manually assign the relevant alphabet taxonomy term with each country from its edit screen.

Note: if you're comfortable with PHP code, you can also automate this process of taxonomy term assignment, using the code shared in the following guide (step 3):
hidden link

Once all countries have a starting alphabet's term assigned, you can create a view to show a list of these taxonomy terms, with a link to their term archive pages.
( ref: https://toolset.com/documentation/getting-started-with-toolset/create-and-display-custom-lists-of-content/ )

You'll also be able to filter your existing view's query using this new taxonomy, as explained in our documentation:
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

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

regards,
Waqar

#1123876

Ben

Thank you for the detailed instructions and information Waqar! Very kind of you. I have got this all sorted now.