In version 7.3 the ThemeFusion team added conditional rendering to the Avada toolset, but what they didn’t do is explain all of the possible use cases. The initial focus in on Woo-commerce, user roles, and as a replacement for the visibility settings on device types. Even their overview only gives you a basic glimpse into the power. In a couple of projects at work I have discovered how powerful they can be especially combined with custom fields and dynamic data. The one drawback is that it is limited to columns — standard and nested — and containers, but nested columns are really the key at this point.
Rendering based on an empty value
Scenario 1 : Subtitle
The first time I ran across an undocumented feature is when I was working on a blog layout. In this design I have the excerpt text displayed below the title of a post, but I also have a custom field for a subtitle. The latter is seldom used, but when it is I don’t want both the subtitle and the excerpt to show. I was thinking, it would be really nice if the dynamic element allowed me to have a fallback of the excerpt. While this may be possible since the before and after fields can use Avada shortcodes, I haven’t tested it in the fallback. As I looked at the screen I started thinking about conditional rendering and would it be possible to have an if-then condition — if the subtile is null, show the excerpt. What I found is that you can do just that — if the custom field “subtitle” is empty. Since the dynamic data for the subtitle has a fallback of nothing, it is not displayed by default. I built a custom title bar and placed each element into its own nested column.
Fortunately, this is really simple to build.
- Open the conditional rendering logic options and choose custom field
- Add the custom field ID
- Leave the value field blank
Scenario 2: Special Label
The scenario and setup is essentially the same as the previous with only one small variation. In this case we need to display that an official biography is only available for historic purposes and that the person is no longer part of the organization. I have a set of custom fields for a biography that include a start year and an end year. While the person is with the company, the end year is blank and has a fallback of “present.” When the individual departs, the departure year is added. In this scenario the condition is set to render when the custom field “departure_year” is not equal to blank. I could have added a checkbox field with a set value, but this minimizes the need to update two field when a person departs.
This is just the beginning of my exploration of the conditional rendering logic and I expect in the near future that these features will be expanded to allow even more options.
Originally published on June 24, 2022
Thank you! I so need this to work for my application of “if there’s no featured image in the blog post, display an ACF field with a video link instead”. I don’t think this is possible yet as there is no condition type for featured image. :(
The conditional rendering is currently limited to containers and columns. They are planning to extend this capability and you can vote on it (https://theme-fusion.com/engage/feature-voting/). The solution for what you want is to place the image element and the video element in their own nested columns and then show or hide based on the presence of the video url.