Archived topic
Template tags visible on frontend when field doesn't exist
1 reply · Started by Octane Marketing on August 12, 2021
We're using GeneratePress Elements to add page headers across a website. Most of these pages uses a {{custom_field.subtitle}} to output the subtitle custom field. This works great except for pages where that subtitle doesn't, or can't, exist. An example of one of these pages is here: https://www.rockinroadtrip.com/2021/08/
As you can see, the {{custom_field.subtitle}} is visible on the frontend because we have no custom fields on those date archives. I would rather this didn't show {{custom_field.subtitle}} when empty/missing.
We're already using ACF to add a "subtitle" custom field to prevent this issue from happening on category archives but that's not possible, or reasonable, on date archives.
Any ideas? Recommendations? Updates to Elements?
Hi there,
The easiest solution would be to create a separate header element without the template tag for the date archives.
Let me know if this helps :)