Home › Forums › Backend Issues (wp-admin) › Collapsed Field Groups as Default
Hi, I couldn’t find this anywhere.
Is there a way to collapse field groups as the default? Feel like this should be an option when creating groups.
It can be confusing for a user when presented with a long list of custom fields on a small screen.
Thanks for any help with this!
Sorry @manonatelier, Im not exactly sure where you are talking about?
When you go to make a new post with custom fields? or when you are designing your fields? or some other time?
Cheers,
Sorry! I hope this makes it clearer.
I’m talking about the “Standard WP Metabox”.
Is there a way to have it collapsed (folded up – and all fields in the field group hidden) as a default, instead of expanded (all fields showing in that field group) in the control panel whenever a user goes to the page edit, post edit, or options edit screens?
Hi @manonatelier,
Thanks for the clarification. I do not believe this is possible. I will raise a feature request for Elliot to take a look at for you.
Thanks for your patience. 🙂
Ok, thanks! When you guys have figured it out, can you send me word? Thank you again!
+1
I would LOVE this feature! I have a page with a ton of field groups, which makes for a very intimidating user experience. I’d prefer that the meta boxes start collapsed, so they can choose to expand the boxes they wish to edit.
[update]
In case anyone stumbles across this, I found an interim solution using javascript. Install this plugin: http://wordpress.org/plugins/add-admin-javascript/
And then, on the plugin settings page, in the “JQuery” box, paste this code:
$('.acf_postbox').addClass('closed');
You may want to edit the .acf_postbox to be more specific, but this will collapse ALL acf meta boxes on page load.
It can be solved without plugin.
<?php
add_action('acf/input/admin_head', 'my_acf_input_admin_head');
function my_acf_input_admin_head() {
?>
<script type="text/javascript">
jQuery(function(){
jQuery('.acf_postbox').addClass('closed');
});
</script>
<?php
}
Only this worked for me for ACF 5.4
function my_acf_admin_head() {
?>
<script type="text/javascript">
(function($){
$(document).ready(function(){
$('.layout').addClass('-collapsed');
$('.acf-postbox').addClass('closed');
});
})(jQuery);
</script>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_head');
I know this is a super old thread, but thought I would share my improvements to the solution above.
– I’m hiding the content with CSS at first to prevent page jump and them being momentarily visible while the page loads. This CSS is then removed once JS has been applied.
– Just adding the -collapsed
class to .layout
was making other elements on the page (like metaboxes) also collapse.
function ACF_flexible_content_collapse() {
?>
<style id="acf-flexible-content-collapse">.acf-flexible-content .acf-fields { display: none; }</style>
<script type="text/javascript">
jQuery(function($) {
$('.acf-flexible-content .layout').addClass('-collapsed');
$('#acf-flexible-content-collapse').detach();
});
</script>
<?php
}
add_action('acf/input/admin_head', 'ACF_flexible_content_collapse');
@louiswalch – many thanks for this approach. Have updated to only auto-collapse repeaters in the admin area (working in ACF Pro – version 5.6.10)
function rdsn_acf_repeater_collapse() {
?>
<style id="rdsn-acf-repeater-collapse">.acf-repeater .acf-table {display:none;}</style>
<script type="text/javascript">
jQuery(function($) {
$('.acf-repeater .acf-row').addClass('-collapsed');
$('#rdsn-acf-repeater-collapse').detach();
});
</script>
<?php
}
add_action('acf/input/admin_head', 'rdsn_acf_repeater_collapse');
Find the includes/admin/views/field-group-options.php file
Open it
Find in code
acf_render_field_wrap(array(
'label' => __('Style','acf'),
'instructions' => '',
'type' => 'select',
'name' => 'style',
'prefix' => 'acf_field_group',
'value' => $field_group['style'],
'choices' => array(
'default' => __("Standard (WP metabox)",'acf'),
'seamless' => __("Seamless (no metabox)",'acf'),
)
));
after line
‘seamless’ => __(“Seamless (no metabox)”,’acf’)
add new line
‘default closed’ => __(“Standard Collapsed”,’acf’)
Result
acf_render_field_wrap(array(
'label' => __('Style','acf'),
'instructions' => '',
'type' => 'select',
'name' => 'style',
'prefix' => 'acf_field_group',
'value' => $field_group['style'],
'choices' => array(
'default' => __("Standard (WP metabox)",'acf'),
'seamless' => __("Seamless (no metabox)",'acf'),
'default closed' => __("Standard Collapsed",'acf'),
)
));
Save.
Go to settings for any group field
Open “Style” list box
Select “Standard Collapsed”
Update
Have a fun
The topic ‘Collapsed Field Groups as Default’ is closed to new replies.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.