My end goal is to conditionally display a heading. To do this, I’m trying to create logic to validate against the value of ACF fields, but no matter what I try, it fails to work properly. In other cases I’m using if statements to see if a field has a value using the “check” method, which does seem to work, but nothing with value=“Some Text”.
I have tried some simple If statements, If-Else, If-EsleIf-Else, and Switch, all with the same results. I don’t care what method I use, as long as it works.
Below is the code that I currently have in my template, and at the end are 3 different links that would would satisfy each of the conditions of the switch statement. I have also tried using local variables vs. direct ACF variables, but get the same results, as you will see code for both options attached as well.
<Set local=service2_type><Shortcode>[acf field="funeral-service-type-2"]</Shortcode></Set>
<Set local=service2_other><Shortcode>[acf field="funeral-service-other-2"]</Shortcode></Set>
<p>
local type= "<Get local=service2_type />"
<br />
local other= "<Get local=service2_other />"
</p>
<If Field="service-type-2" is value="No Service">
<p style="color:#f00;"> - Local - No Service If Statement -</p>
</If>
<Switch Field="service-type-2">
<When value="No Service" />
<p style="color:#f00;">- Local - No Service Switch Statement -</p><br />
<When value="Other" />
<h4><Get service2_other /></h4>
<When />
<h4><Get service2_type /></h4>
</Switch>
<br />
<hr style="border-bottom: 2px dashed #f00;" />
<br />
<p>
acf type= "<Field funeral-service-type-2 />"
<br />
acf other= "<Field funeral-service-other-2 />"
</p>
<If Field="funeral-service-type-2" is value="No Service">
<p style="color:#f00;"> - ACF - No Service If Statement -</p>
</If>
<Switch Field="funeral-service-type-2">
<When value="No Service" />
<p style="color:#f00;">- ACF - No Service Switch Statement -</p><br />
<When value="Other" />
<h4><Get service2_other /></h4>
<When />
<h4><Get service2_type /></h4>
</Switch>
The links below are provided as example pages for each of the 3 conditions. Results show in the grey box in the right sidebar of the page.
Value = “No Service”
Value = “Other”
- /joseph-f-big-joe-guilfoile-jr/
Value = Any other condition.
- /martha-bane/
So, as a new user, the system limiting the number of links I can add, so I’m removing the domain reference from the last 2 links.