Skip Navigation

[Resolved] Add icon to taxonomy terms in Content template

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

Last updated by Waqar 1 year, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2656503

Hello,

What is the best way to add icons to taxonomy terms in a Content template?

Thanks!!

#2656733

Hi,

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

There is no direct block or function available for this, so it will require the following steps:

1. You can add an image type term field 'Term Image Icon' from WP Admin -> Toolset -> Custom Fields -> Term Fields.

This will allow you to attach an image icon, with each of your target taxonomy's terms.

2. Next, you can create a taxonomy view that can show the list of the terms attached to the current post. In that list, you can include this image icon from the term field too, along with the term title.

Important note: Taxonomy views are only supported when using the classic views editor. If you're not already using them on the website, you can go to WP Admin -> Toolset -> Settings -> General and select "Show both the legacy and Blocks interface and let me choose which to use for each item I build" option for the "Editing experience".

After that, you'll be able to create a taxonomy view, from WP Admin -> Toolset -> Views.

If you haven't used the classic editor for views before, you'll find the documentation related to its features at:
https://toolset.com/documentation/legacy-features/views-plugin/

Here is another forum thread, where the steps for creating a taxonomy view for a similar requirement are explained:
https://toolset.com/forums/topic/split-showing-different-images-for-different-taxonomy-terms/#post-1965179

3. In the loop of this taxonomy view, you'll be able to show this image icon from the term field and the title of the term like this:


[types termmeta='term-field-slug' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types] [wpv-taxonomy-title]

Note: You'll replace 'term-field-slug' with your actual field's slug.

Related documentation on shortcodes used:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2657299

Worked perfectly thank you!

Is it possible to link the image icon to the term URL?

#2657303

Glad that it worked!

To wrap the icon inside the term archive link, you can use the 'wpv-taxonomy-url' shortcode like this:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-url )


<a href="[wpv-taxonomy-url]">[types termmeta='term-field-slug' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types]</a>

#2657399

Great! Thank you for you help.