I’m relatively new to HUBL, but learning lots. I’m stuck on this problem… but, I feel like I’m close (maybe?).
The goal is to have a CHOICE field in my blog post. This is working correctly with this line of code in the “Additional <head> markup” box:
{% choice "blogType" label='Choose the blog type', value='Featured', choices='Featured, Latest, New', export_to_template_context=True %}
The problem is retrieving that choice and showing the result. The code I’ve currently got in the Custom HTML box is:
{% set tag_posts = blog_recent_tag_posts('default', 'Apparel', 2) %}
<div class="featured-posts">
{% for tag_post in tag_posts %}
<div class="item">
<div class="post-image" style="background:#333333 url('{{ tag_post.featured_image }}')no-repeat;">
<div class="item-wrapper"><button class="featured-pillbox">
{% if widget_data.blogType.value %}
{{ widget_data.blogType.value }}
{% endif %}
</button>
<div class="title-wrap">
<div class="post-title"><h2><a href="{{ tag_post.absolute_url }}">{{ tag_post.name|truncate(100,true,'...') }}</a></h2></div>
<div class="author-data">
{%if tag_post.blog_post_author %}
<a class="author-link" href="{{ group.absolute_url }}/author/{{ tag_post.blog_post_author.slug }}"><span style="font-weight:400!important;">By</span> {{ tag_post.blog_post_author.display_name }}</a>
{% endif %}
</div>
</div>
</div>
<div class="read-more-link">
<a href="{{ tag_post.absolute_url }}"></a>
</div>
</div>
</div>
{% endfor %}
</div>
The issue, I’m sure, is in the following lines. It’s calling the choice field in the head, but only outputting the default value.
{% if widget_data.blogType.value %}
{{ widget_data.blogType.value }}
{% endif %}
So, the question is… what do I wrap this in (or do differently) so that it recognizes which post it’s pulling from, and then pull the value set in the blog post?
Any help is sincerely appreciated. Much thanks, in advance, for your assistance.
Jeff T.


