Hi all, I’ve spent hours trying to hide metafields in blog posts when they are empty and I can’t get anything to work.
I want to add metafields for a featured product and a featured collection at the end of my blog posts: but I want to hide them when they’re not assigned. I’ve set up the metafields (blog-product and blog-collection).
I’ve watched/read several solutions and haven’t gotten any to work. The following one responded, but hides ALL metafields - whether they’re assigned or not:
{% if collection.metafields.custom.blog-product == blank %}
#shopify-section-template--16710703251698__featured_product_3JWUiz {display: none; }{% endif %}
As you can see, I added them within the shop editor on the “blog post” settings.
Does anyone have any solutions for this? It’s a handy feature, if I can get it to display only when it’s populated ![]()
