Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Advanced custom fields - conditional logic

I'm creating a two column layout in WP and using the ACF plugin to help editors create content. Is there are feature in ACF that will allow editors to enter content in a field then select if the field will display in the left or right column? If not, is this a capability that can be added to ACF? Thanks.

3 Answers

John Locke
John Locke
15,479 Points

Jesse: What sort of content is going into the editor fields, and do you have just a simple two column layout? Which fields are you you using for your editors?

Hi John,

The layout is quite complex:

The left column will involve text (using the ACF WYSIWYG editor) copy along with the option to include video and/or a client testimonial

The right column will involve a flexible combination of video, an image, testimonial along with HTML text (again with the WYSIWYG editor)

One option (always the easy option that escapes me) is to create fields for all elements in both columns but designate the column for each field. This sounds the least complicated ....

John Locke
John Locke
15,479 Points

But each chunk of content is one complete blob on its own? Or you're putting together a testimonial, then an image or video to create a larger chunk?

It might be easier to make the column choice at the very start. The other choice might be to add a CSS class depending on the checkbox.

Make the process as client-proof as possible, and as easy as you can, first. THen think about what solutions are possible from there, where you've done all the work for them behind the scenes.

Hi John,

Yes, the choice outline earlier is a big blob. It would be ideal if we could either provide a left and right column fields or allow editors to use a radio button. Can you provide a very quick outline on how I can achieve this:

"It might be easier to make the column choice at the very start. The other choice might be to add a CSS class depending on the checkbox."

Thanks.

John Locke
John Locke
15,479 Points

I was about to write something entirely different, but I found this page which explains it better than I could.

https://spruce.it/noise/highly-flexible-layouts-using-acf-flexible-content-fields-repeater-fields/

Also reference here: http://www.advancedcustomfields.com/add-ons/repeater-field/ and here: http://www.stormconsultancy.co.uk/blog/development/dev-tutorials/creating-flexible-content-with-advanced-custom-fields/

This is an entirely different type of solution, a little bit more complex, but potentially less of a headache once you get it set up: http://wp.smashingmagazine.com/2011/10/14/advanced-layout-templates-in-wordpress-content-editor/

Hi John,

Ah many thanks!