Skip Navigation

[Resolved] Displaying custom icons as markers on map – related to taxonomy

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

Problem:

I have to display different icons (png) in the template according to custom taxonomy (categories and subcategories).

Solution:

This is possible with a taxonomy view + a custom taxonomy image field, for example:

1) Create a taxonomy image field "my-icon"

2) Dashboard-> Toolset-> Views, Create a taxonomy view, for example "my-view"

- Query terms of your taxonomy "categories"

- Filter by:
Taxonomy is set by the current post

- In view's loop, display the custom image field "my-icon" shortcode

3) In single post content, display above taxonomy view shortcode, for example:

[wpv-view name="my-view"]

Relevant Documentation:

https://toolset.com/course-lesson/creating-custom-fields/

This support ticket is created 3 years, 8 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 3 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1722787
Attachment 02.jpg
Attachment 01.jpg

Hi,

I've stumbled upon 2 problems I can't resolve.

1. I have to display different icons (png) in the template according to custom taxonomy (categories and subcategories). See attachment 01 and 02.

2. I have a map that displays related child posts as markers. It will be super cool if the map could display custom markers (icons) related to a taxonomy (categories). The map will use the same icons (markers) as in the first question above. You can check the map following this link hidden link

What is the link to your site?
hidden link

Thanks

#1723475

Hello,

Q1) This is possible with a taxonomy view + a custom taxonomy image field, for example:
1) Create a taxonomy image field "my-icon"
https://toolset.com/course-lesson/creating-custom-fields/

2) Dashboard-> Toolset-> Views, Create a taxonomy view, for example "my-view"
- Query terms of your taxonomy "categories"
- Filter by:
Taxonomy is set by the current post
- In view's loop, display the custom image field "my-icon" shortcode

3) In single post content, display above taxonomy view shortcode, for example:
[wpv-view name="my-view"]

Q2) It is super cool, but there isn't such kind of built-in feature within Toolset plugins, and there will a problem, if a child post has 2 more category terms, which icon do you want to use for map marker icon?

#1723723

Hi Luo,

thanks for the help. Q1 is now resolved following your instructions.

Q2 - Yes, it is rather complicated to achieve this. If the child post has 2 or more category terms maybe the third icon will appear, some kind of conditional?

#1725297

As I mentioned above, there isn't such kind of built-in feature within Toolset plugins, you will need to consider custom codes, for example, create a custom shortcode with PHP function:
https://developer.wordpress.org/reference/functions/add_shortcode/
In the PHP function, get term's of current post:
https://developer.wordpress.org/reference/functions/wp_get_object_terms/
Find the term item you want, and return the taxonomy image field value:
https://developer.wordpress.org/reference/functions/get_term_meta/

#1725587

Ok, thanks Luo.

For now, I will stick to the default markers. Thank you for your help with other questions.

My issue is resolved now, you can close this ticket as resolved.

Best

#1726379

Close this ticket.

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