The theme I’m building has two page template types: standard (standard fields – editor, title etc.) and flexible (the user adds components to the page to build the layout).
The flexible template uses the flexible content add-on to create the components which the user will add to a page.
What I want to do is hide the WYSIWYG editor when the flexible template is selected in the ‘Template’ option when adding/editing a page. Then, if the standard template is selected, show the editor again.
Here are the rules for my field group:
Show field group if:
Post Type = ‘page’ AND Page Template != ‘Standard Template’
I’ve also ticked the ‘Content Editor’ option under the ‘Hide on Screen’ options.
Now, this kind of works (when I select my flexible template, the editor disappears) but when I change the template back to standard, it doesn’t show the editor again until I save and reload the page.
Is this intended functionality or am I doing something wrong here?
The hide/show (CSS) is loaded via AJAX each time a field group is shown/hidden.
The CSS is only loaded based on the first field group that is shown.
Perhaps it is the order of field groups which is preventing the correct CSS from loading.
You can check the CSS returned from the AJAX call in your console log to help you figure out which field group is loading first
Hi elliot, Thanks for getting back to me.
I’m only using one field group at the moment. I basically have one field group called ‘Components’ which I show on the add/edit screen when ‘Default Template’ is selected. Otherwise, I don’t want to show any custom fields. And that works as expected, I select a different template and the field group disappears.
But, under the options for the components field group, I’m hiding the editor. But, when another template is selected, I want the custom fields to go (which they do) and the editor to come back (which it doesn’t). Is that possible?
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2021 Advanced Custom Fields. Subscribe