That is correct. If the field is added after the post is created the field will not have the default value until the post is updated. ACF does not retroactively set default values.
True/False fields are a little tricky because ACF will return false for it if it is not set or if it is not checked.
The best way, in my experience, to deal with this is to use
<?php $show_sidebar = get_post_meta($post->ID, 'show_sidebar', true); if($show_sidebar === '' || $show_sidebar === '1'): ?> <div id="sidebar"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?><?php endif; ?> </div> <?php endif; ?>
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!
© 2023 Advanced Custom Fields.