Skip Navigation

[Resolved] Creating a-z alphabet list from custom taxonomy

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a grid of all the letters in the alphabet, and use those as filters for a custom search View. When you click a letter, the View should load posts filtered by a custom taxonomy term that corresponds the artist's name. The first letter of the artist name should be the same as the letter filter the User clicks.

Solution: WordPress does not allow searches by the first letter of a taxonomy term, so a workaround is required. In addition to applying the artist name as a taxonomy term, you must also apply a term from a separate custom taxonomy that represents the first letter of the artist's name. Your custom search View must filter by this taxonomy "letter" term. Create the grid of alphabetical letter filters using your own custom HTML, or use the built-in filter types to automate this filter list and use custom CSS to manipulate the styles for each filter.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/filtering-views-by-taxonomy/
https://toolset.com/course-lesson/creating-a-custom-search/

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

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by ivanaS 3 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1776027
A-Z.png

Tell us what you are trying to do? Hi there, on our website we have video art library, videos from Facebook embedded with Custom Facebook Feed Pro Business from Smash Balloon. Every video is linked to a post on our website, and every post is from different artist. With toolset I have created custom taxonomy called "artist" and in every post I have add appropriate artist name in that field. Since the Art library is very big, it would be great to have A-Z listing based on artist name, and as I said earlier, their name is in the taxonomy "artist". Is it possible to create such a alphabet list with toolset or do I need some other, external, plugin? I tried with "Tag Groups" from Chatty Mango, but there seems to be a conflict of this plugin with Toolset, so does not work properly. Would be grateful for your advise and suggestions, maybe you know how to do this with Toolset, or suggest some plugin which will do the job?

Is there any documentation that you are following? Have read some forums but did not find a solution.

Is there a similar example that we can see? Very simple squares with letters A,B,C,D.....where when you click on one letter, shows all artists on letter A or B or..... something like A-Z listing plugin (hidden link) but I did not succeed to solve my problem with that plugin.

What is the link to your site? hidden link

#1776425
query-filter.png

Hello, in Views there is no built-in system for creating filters based on the first letter of taxonomy term(s) applied to a post. This is a limitation that exists because of WordPress's taxonomy query system. It's not possible to do searches for posts by the first letter of a term because the query does not support wildcards in the term slug or term name.
operator (string) – Operator to test. Possible values are ‘IN’, ‘NOT IN’, ‘AND’, ‘EXISTS’ and ‘NOT EXISTS’. Default value is ‘IN’.
You would need to be able to use a "LIKE" operator to use wildcards: A% is the letter A followed by a wildcard %. This translates to the first letter is "A", followed by any other information.
The wildcard operator is supported for custom field searches, so you can query for posts with custom field values LIKE A%, which would provide results with custom fields that start with the letter 'A'. If you decided to move the artist name into a custom field, you could take advantage of this and another taxonomy might not be needed. However, since you want to use a taxonomy to store the artist name, a slightly different setup is required. In addition to terms for each artist name, you must create a separate custom taxonomy that includes just the first letter of the artist name. Terms in this taxonomy are like A, B, C and so on through Z. These terms are applied to each artwork post in addition to the artist name terms.

To display the filtered results, you would then create a View of the artwork posts. Apply a Query Filter to this View to filter on the first letter taxonomy term slug. Configure the term slug Query Filter to respond to a URL parameter like "alpha". See the query-filter.png screenshot here for an example of this Query filter configuration.

This Query Filter setup will respond to a URL parameter, so no matter how you decide to display the filters the end result will use URLs like this to display filtered results on a custom Page called "Artists by First Letter of Name", for example:
- yoursite.com/artists-by-first-letter-of-name/?alpha=a...this page will show artists whose name starts with the letter "a".
- yoursite.com/artists-by-first-letter-of-name/?alpha=b,c,d...this page will show artists whose name starts with letters b, c, or d
- yoursite.com/artists-by-first-letter-of-name/...this page will show all artists

The filters your Users interact with to update the search results are another challenge to overcome. Views does not offer custom search View filters that look like text letter links in a grid. In other words, the grid of letter filters is not something that Toolset will easily create automatically. The types of filters that can be automatically created by Views are dropdowns (also known as select fields, only allow one selection), multiple select fields (these allow multiple selections but are not flexible in terms of display style), free-text inputs (not ideal because of the possibility of adding garbage text in the input, allows multiple selections), radio buttons (not ideal when you have 26 options, allows only one selection), and groups of checkboxes (another way to allow multiple selections). If you are a CSS developer, you might be able to create and style radio button filters so they look like text links in a grid of letters. It's quite an advanced CSS technique, so if you're not familiar with developing your own stylesheets this isn't a good solution. You would need a developer to get this just right.

Another option for the filters is to create the markup using hard-coded HTML and CSS. Each letter would be created as an HTML text link, with the corresponding term slug filter URL hard-coded, like this:

<a href="<em><u>hidden link</u></em>">A</a>
<a href="<em><u>hidden link</u></em>">B</a>
...
<a href="<em><u>hidden link</u></em>">Z</a>

This gives you full flexibility in terms of style and display of the filter letter grid, but it has limitations. Some features of Views are not available if you create your own custom filter markup HTML. "Only show available options for each input" for example, is a feature that will hide or deactivate filter options in cases where selecting that filter option would produce no results. It's a nice feature for usability because your visitors can easily see what is available at a glance, without clicking filters and waiting to see "No items found". However, this option is not supported if you create your own filter markup.

I thought I would give you some ideas about how this might be created in Toolset and present pros and cons for each option. Now that you have this information, I hope you can make the choice that's best for your site and Users. Feel free to let me know if you have follow-up questions and I will do my best to give you more information.

#1776663

Thank you very much for your assistance. I will do my best to follow your detailed instructions and try to find a way to solve my issue.

Best regards,

Ivana

#1776665

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.