Okay
  Public Ticket #2692117
Displaying taxonomy values in a Posts Grid
Closed

Comments

  • Barry Goodwin started the conversation

    Hi Amit,

    I have the code at the bottom of this message which perfectly displays a posts grid with additional custom fields below the post title. 

    I'd like to add data relating to a custom taxonomy also. I have one custom taxonomy called 'Display Status' with a tick box for 'Today' amongst other options. If the term 'Today' is ticked for a post, I'd like to show the value 'Yes' in the content alongside the custom fields in the post grid. Is that possible?

    If not, I'll create a taxonomy called 'Today' and have two terms, 'Yes' and 'No' so that it might be easier to be able to ask for 'If post term value = Yes, then display 'Yes' etc.

    Please let me know if that's possible.

    Many thanks, Barry.

    <div class="uc_post_grid_style_one_item ue_post_grid_item">
     <a class="uc_post_grid_style_one_image" href="{{item.post_list.link}}">
       <div class="uc_post_image" style="background-image: url({% if item.post_list.image is empty %}{{uc_assets_url}}/no-image.png{% else %}{{item.post_list.image}}{% endif %});"></div>
      </a>
     
     <div class="uc_content">
        <div>
        {% if show_title == "true" %}<div class="uc_post_title"><a href="{{item.post_list.link}}">{{item.post_list.title|raw}}</a></div>{% endif %}
          <div>{{item.post_list.cf_nationality}} - {{item.post_list.cf_age}} yrs</div>
          <div>{{item.post_list.cf_statistics}}</div>
        {% if show_date == "true" %}<div class="uc_post_date">{{item.post_list.date|ucdate("d F Y")|raw}}</div>{% endif %}
        {% if show_text == "true" %}<div class="uc_post_text">{{item.post_list.intro_full|truncate(intro_number_of_characters)}}</div>{% endif %}
        {% if show_button == "true" %}<div class="uc_post_button"><a class="uc_more_btn" href="{{item.post_list.link}}">{{button_text}}</a></div>{% endif %}
      </div>
      </div>
    </div>

  • Barry Goodwin replied

    Hi Amit,

    Not to worry. I managed to fix it by reading through other support tickets and cobbling something together. I changed the taxonomy and just pulled the single of value the one term and that's all I need for now. Please close this ticket and if there's a way of me being able to close it please let me know.

    This is the code I used if it helps anyone else. The term I needed to get was 'working-today' which is referenced below. 

    <div style='color:red;'>Working Today: {% set terms = getPostTerms(item.post_list.id, "working-today", true) %}
         
    {% for term in terms %}

            <strong>{{term.name}}</strong>

    {% endfor %}</div>


    Many thanks,

    Barry.

  •   Max replied privately