It’s not pretty when one looks at the source code, but I use the token in the CSS classes of the element and then look for when the class is not rendered right and hide it. This CSS trick can allow you to conditionally show or hide anything, depending on if the field is null or not (or a specific value):
CSS:
/* Hide empty bullets */
[class^=”-Location”], [class^=”-Food-Location”]
{ display:none; }
HTML:
<h3>locations include:</h3>
<ul>
<li class="{{mpg_check-in_location}}-Location"><a href="{{mpg_check-in_loc_link}}" target="_blank" rel="noopener">{{mpg_check-in_location}} (Check-In Here)</a></li>
<li class="{{mpg_location_2}}-Location"><a href="{{mpg_loc_2_link}}" target="_blank" rel="noopener">{{mpg_location_2}}</a></li>
<li class="{{mpg_location_3}}-Location"><a href="{{mpg_loc_3_link}}" target="_blank" rel="noopener">{{mpg_location_3}}</a></li>
<li class="{{mpg_location_4}}-Location"><a href="{{mpg_loc_4_link}}" target="_blank" rel="noopener">{{mpg_location_4}}</a></li>
<li class="{{mpg_location_5}}-Location"><a href="{{mpg_loc_5_link}}" target="_blank" rel="noopener">{{mpg_location_5}}</a></li>
<li class="{{mpg_location_6}}-Location"><a href="{{mpg_loc_6_link}}" target="_blank" rel="noopener">{{mpg_location_6}}</a></li>
<li class="{{mpg_location_7}}-Location"><a href="{{mpg_loc_7_link}}" target="_blank" rel="noopener">{{mpg_location_7}}</a></li>
<li class="{{mpg_location_8}}-Location"><a href="{{mpg_loc_8_link}}" target="_blank" rel="noopener">{{mpg_location_8}}</a></li>
</ul>
<h3 class="{{mpg_food_location_1}}-Food-Location">And food locations include:</h3>
<ul>
<li class="{{mpg_food_location_1}}-Food-Location"><a href="{{mpg_food_loc_1_link}}" target="_blank" rel="noopener">{{mpg_food_location_1}}</a></li>
<li class="{{mpg_food_location_2}}-Food-Location"><a href="{{mpg_food_loc_2_link}}" target="_blank" rel="noopener">{{mpg_food_location_2}}</a></li>
<li class="{{mpg_food_location_3}}-Food-Location"><a href="{{mpg_food_loc_3_link}}" target="_blank" rel="noopener">{{mpg_food_location_3}}</a></li>
</ul>
Hi @mikeathanson,
Thank you for using MPG.
I understand your request, and, at the moment, there isn’t a built-in feature within the plugin that allows for a custom fallback when an MPG shortcode like {mpg_location} doesn’t have a value to replace it with. Currently, the plugin will simply insert the raw shortcode text into the generated page.
However, I appreciate your suggestion, and I’ll make sure to log it as an enhancement request to be analyzed for future updates.
Thank you, @edgepro for sharing a potential solution to this particular use case.
Wish you a great day ahead!
@stefancotitosu this should be considered core functionality – I am really surprised mpg launched without it.