Handle empty values and fallbacks
Optional data needs deliberate markup. Most merge tags return no output when their source value is empty, but the surrounding HTML remains.
Prevent empty wrappers
Feed and single templates support conditional blocks based on a custom field:
{{if meta="venue" value="not_empty"}}
<p class="venue">{{meta name="venue" only_content="true"}}</p>
{{/if}}
Use {{else}} when an alternative message is useful:
{{if meta="booking_url" value="not_empty"}}
<a href="{{meta name="booking_url" only_content="true"}}">Book now</a>
{{else}}
<span>Bookings are not open.</span>
{{/if}}
The comparison may use an exact value, empty or not_empty.
Content fallback
Feed templates use {{post_content}}; single templates use {{content}}. Both accept fallback_message:
{{post_content fallback_message=%%No summary is available.%%}}
{{content fallback_message=%%No description is available.%%}}
On password-protected single content, the password form takes precedence over the content fallback.
Image fallback
In a feed template, {{featured_image_url}} accepts a fallback URL:
<img
src="{{featured_image_url image_size="medium" fallback_url="/wp-content/uploads/card-placeholder.jpg"}}"
alt="{{title}}"
>
For WooCommerce products, {{featured_image}} uses the WooCommerce placeholder unless hide_default="true" is supplied.
Single-template featured images do not expose those feed-only fallback attributes. Use conditional content design or ensure the content model requires the image.
Archive term values
Term-specific tags such as {{term_description}}, {{term_thumbnail}}, {{term_bg_image}} and {{term_color}} are empty when the current archive has no matching term value. Archive templates do not support the feed/single {{if}} block, so avoid placing essential text inside a term-only field.
{{parent_term_id fallback="current"}} can return the current term ID when a top-level term has no parent. A numeric fallback is also accepted.
Verification matrix
Test at least:
| Case | What to check |
|---|---|
| Fully populated item | All dynamic values and assets render |
| Missing optional meta | No empty heading, icon or wrapper remains |
| Missing featured image | The chosen fallback behavior is acceptable |
| Empty main content | The fallback message is displayed |
| Top-level taxonomy term | Parent-term fallback behaves as intended |
| Password-protected item | The password form remains available |