Display custom taxonomy field - sIngle Image - type when term is selected

Support MB Views Display custom taxonomy field - sIngle Image - type when term is selectedResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34522
    Chris PChris P
    Participant

    So I got this custom field added to a taxonomy and via the insert buttons I was able to display the term name in a single custom post type 'project'. But I can't seem to figure out how to display the corresponding image I set via the custom field to that taxonomy. Any help would be greatly appreciated.

    Here's my code to output the title::

    {% for item in post.taxonomy_award %}
        <a href="{{ item.url }}">{{ item.name }}</a>
    {% endfor %}

    But I added a custom field to the taxonomy_award. Namely
    Label Award logo
    ID*. single_image_awards
    Type Single Image

    I tried the following examples but failed:

    {% set image = mb.rwmb_meta( 'single_image_awards', '', post.ID ) %}
    
    <img src="{{ term.single_image_awards.thumbnail.url }}" width="{{ term.single_image_awards.thumbnail.width }}" height="{{ term.single_image_awards.thumbnail.height }}" alt="{{ term.single_image_awards.thumbnail.alt }}" />
    #34527
    Long NguyenLong Nguyen
    Moderator

    Hi Chris,

    In View, you can use this code to output term meta in the single post

    {% for item in post.taxonomy_award %}
        <a href="{{ item.url }}">{{ item.name }}</a>
        {% set image = mb.rwmb_meta( 'single_image_awards', { object_type: 'term' }, item.term_id ) %}
        <img src="{{ image.full_url}}" />
    {% endfor %}

    Please follow this documentation to know how to output term meta value https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value

    #34571
    Chris PChris P
    Participant

    Ok thx, worked like a charm!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.