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.
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
Thank you for the detailed instructions and information Waqar! Very kind of you. I have got this all sorted now.