Revisiting Pods and Beaver Themer; Conditional Field Connections

Beaver Themer & Pods - Limitations

Revisiting Pods and Beaver Themer; Conditional Field Connections

At the last WordCamp Kent, I gave a presentation about building darn-near any kind of website using Pods and Beaver Themer. Someone had asked why I preferred Pods for custom post types and custom fields to ACF & CPT. I didn’t have much of a preference back then, except for the benefit of managing everything within one plugin rather than 2.

I have come to find one vital limitation with Pods and Themer though – testing conditionals for values. With Pods and Themer, you can only do all-or-nothing conditional field connections in a shortcode; “if there is something in this field, then display this”.

[wpbb-if post:pods_display field='field_name']
<ul>
<li>If there's something/anything in that field (field_name), this content will show.</li>
<li>If it's blank, this list will not appear.</li>
</ul>
[/wpbb-if]

This is valuable when you don’t want a blank space to appear. However, if you need it to be value-based, Beaver Themer can only help you if you’re using ACF. I’ve come across a few instances where I need content to change based on a toggle or radio button; relying on a “yes/no” rather than a yes/null.

There is a lot you can do with conditionals, especially if the field is numbers rather than text. I haven’t come across a scenario yet where I needed the content to change if the field value was less-than or equal to, say 100, but here’s an example from a site I built, partakekitchen.com:

[wpbb-if post:acf type='radio' name='vegetarian']
  <div class="mp-label">Vegetarian</div>
    <img src="/wp-content/uploads/2019/03/vegetarian-icon.png?6bfec1&6bfec1" alt="Vegetarian">
[/wpbb-if]

screen shot of conditional shortcode displaying an icon if a box is checked

In this example, if the menu item is labeled Vegetarian, the little vegetarian icon appears.

I felt like I had to do excessive digging to find out that I couldn’t do this with Pods. Any time I have to dig, I have to write about it! So let it be known, value expressions, like those discussed in this Beaver Themer knowledge base article, cannot be performed with Pods custom fields. Only with ACF or Toolset (though I have no firsthand experience with Toolset).

There is, however, a wealth of information in the Beaver Builder KB on using ACF. So much so that they put together a collection of ACF-related field connection KB articles. Then there’s the one little “Build This” article on using Pods and Beaver Themer.

This is not to say that it can’t be done! I know there’s a lot you can do with Pods templates, though I haven’t had any luck using them in Themer. There’s also a thing called Meta Box which has been paired with Pods, but I couldn’t find anything easily digestible on it.

There is a lot of information on the Pods website, but most of it seems to require a lot of advanced WordPress development knowledge. I can handle a little PHP customization, plug-in creation, but I don’t have a good enough grasp on it to freestyle write PHP. That’s why I use a plugin for my custom post types in the first place!

Photo of Abby Lehman Buzon, owner of The Helpful Marketer

About the Author

Abby Buzon

I'm Abby (Armstrong-Lehman) Buzon, Lead Designer & Owner of The Helpful Marketer, based in Medina County, Ohio. I got my start in marketing and website administration in 2010, became a mom in 2015, and left my day job in 2017 to begin The Helpful Marketer. I'm happier than I've ever been and I truly love what I do, so I'm here to share my story and give some marketing tips along the way!

 

5 Comments

  1. Hannu Jaatinen on December 19, 2019 at 4:58 am

    Can’t you use the Conditional Logic for this on the Advanced tab?
    It should work if the icon is in its own module but it probably won’t work if you want to embed the icon in the middle of a, let’s say, Text Editor module

    • Abby Buzon on December 19, 2019 at 7:54 pm

      Thanks for commenting Hannu! I’ll have to look into that more. I have yet to find an instance where the Conditional Logic in the Advanced tab was actually something I could use, but perhaps I haven’t explored all the possibilities of it yet.

  2. Abby Buzon on January 28, 2020 at 10:09 am

    Since Hannu’s comment, I’ve still been looking for opportunities to use the BB modules’ Conditional Logic and have found a few, but still none related to conditional values in a CPT or Pod. The instances where I’ve need a value-based conditional were all within text, namely within a the Custom Layout HTML of a Post module. Post modules themselves end up being 99% of my work with custom post types.
    I suppose you could have the entire Post Module controlled by the conditional Logic and have multiple variations of the Post Module for each of the different conditions though… I love the possibilities for this!
    If anyone has any examples of sites they’ve built using Pods or CPT’s with Conditional Logic or Value Expressions, I’d love to see them – please share a link in the comments!

  3. David on June 9, 2021 at 6:38 pm

    I found this article when trying to solve a specific problem – showing/hiding a module based on a boolean Pods field. I managed to get it working so thought I’d share my solution.

    The problem I wanted to solve was to display one of two different versions (v1, v2) of a testimonial block based on the value of a custom Checkbox field on the Pod.

    I already knew that the way to test a Pods field with Beaver Themer is to use the Post Custom Field to check the Pods custom field (unlike ACF, where Themer’s conditional logic settings include a number of ACF options). You then use the Name of the custom field to specify the field (e.g. single_testimonial in my case). From there you can specify the value this field should have for the condition to be met.

    I use this a lot for displaying content using Is Set or Is Not Set conditions, e.g. “display this row only if the section_heading custom field is set”.

    For this specific scenario, I created a Boolean custom field (“Show v2”) using a Yes/No checkbox that would default to No, unless the customer checked the box. In this scenario, the meta_value for the field would be either 1 or 0.

    I then set the conditional logic on v1 to “Post Custom Field called single_testimonial is not set to 1” and the conditional logic on v2 to the opposite, “Post Custom Field called single_testimonial is set to 1”. This did the trick, and the visibility of v1 and v2 is now being controlled by that checkbox field.

    Note – it is important to be careful how you set up your conditional logic in Pods.

    In theory, I could have set the conditional logic on v1 to “Post Custom Field called single_testimonial is set to 0”. However, I had a number of existing Pods when I added that single_testimonial custom field. At that point, none of the existing Pods had a value set in the postmeta table for the single_testimonial field. This value would only be set by editing and saving each post in turn. The logic I used instead basically said “show v1 unless v2 has been set to 1”. This avoided the need for me to update all posts manually (or via a manual MySQL insert which would also work).

    • Abby Buzon on June 10, 2021 at 12:59 am

      Very cool David! Thanks so much for sharing!
      I’ve had some fun playing with the BB Conditional Logic but I haven’t done much with Pods in the last year – I’ve found ways to use it with The Events Calendar, but it’s tricky sometimes to figure out the field key, esp for Virtual Events. There’s this minimaLIST (haha) from TEC and this one on Github, but both are pre-Virtual Events

Leave a Comment