Tell us what you are trying to do?
I am trying to display the associated custom taxonomy image from a taxonomy term retrieved through custom coded select drop-down field as a URL Image link.
My View is not a Taxonomy View. It is a View of a Repeating Field Group with URL, Text Field, and Select Box. The Select Box pulls its values from a Toolset Custom Taxonomy which has an Image Field. I want to display the URL with the Text Field Label and have the link displayed with the Taxonomy Image associated with the Taxonomy Select Box value retrieved from the Custom Taxonomy List.
Is there any documentation that you are following?
https://toolset.com/forums/topic/how-to-display-the-taxonomy-image/
https://toolset.com/forums/topic/display-taxonomy-image-with-view/
https://toolset.com/forums/topic/displaying-image-link-and-name-of-a-taxonomy/
https://toolset.com/forums/topic/taxonomy-images-issue/
What is the link to your site?
Site is under construction. hidden link
Thanks!
What are the values for each option in the Select Box - term IDs?
If they are IDs, then you can use the Types field shortcode to display the image field associated with the term ID. Types field shortcode examples are available here: https://toolset.com/documentation/customizing-sites-using-php/functions/
So let's say the select box value is a term ID, and the select field slug is "term-select". Let's say the term image field slug is "term-image". To display the term field image associated with the selected term, you would do something like this in a View of the RFG:
[types termmeta="term-image" term_id="[types field='term-select' output='raw'][/types]"][/types]
If the values in the select field are not term IDs, but are term slugs, it's not as straightforward because the Types field shortcode for term fields requires an ID. You would probably need to create a View of terms filtered by term slug using a shortcode attribute in this case, and then output the image inside the term view.
Let me know if I misunderstood the request.
Dear Christian,
I believe you understood the problem perfectly. I used custom code to retrieve the taxonomy terms in the select field.
The end user only sees taxonomy terms in the select field box.
Is there a way for me to indirectly obtain the ID? After all it is pulling the values for the select field from the list of Taxonomy terms.
Once I make a selection from the select field I would like to display the term image associated with with the selected term.
The values in the select field are the Term Name and not the ID or the slug...
Thanks for your help.
There is no simple shortcode to get the term ID given the term name, and anyway you shouldn't set it up like this for multiple reasons. The simplest, most important reason is what I've already told you: the Types field shortcode for displaying a term image field requires a term ID. If you can't use the Types field shortcode, you'll have to write your own custom code to display a term field image, and you won't be able to use any of the image resizing or alignment attributes that are possible with a Types field shortcode.
Furthermore, It will be easier and more error-proof to find and display the name of a term with a known ID rather than going in the opposite direction to get the ID from the name. It is possible to have more than one term in a taxonomy with the same name, for example, but it is not possible to have more than one term in a taxonomy with the same ID. Furthermore, the ID of a term will not change but the name might.
So why do you want to use the term name as a value? We should probably work on solving whatever problem that creates instead. If the issue is you want to display the term names in the select field instead of IDs or slugs because the name is more legible, just use the term name as the option text and use the term ID as the option value:
<option value="123">Term Name</option>
Now you can get the selected option value and use it to display a Types term field image using the Types field shortcode.
What other problem can I help solve when using the selected term ID instead of the term name?
Hi Christian,
Once again thank for the detailed response.
I see the issue. In my implementation of the select box I used custom code to dynamically populate the box option values from a specific Custom Taxonomy list.
The reason was to make that particular function 100% in sync with whatever the terms are in the meta list instead of having to manually duplicate the values in the option field everytime there was a change in name or an addition.
Incidentally, the termmeta image shortcode did retrieve the correct image using the slug alone so so far so good.
I think for now you have given me everything I need in the event my solution doesn't work you have provided details for an alternative so I thank you.
My issue is resolved now. Thank you!