get_field always returns null even with content and page id set
-
I’m using ACF Version 6.2.1
I have this in a template partial, called in my front page template (outside of the loop):
<?php var_dump(get_field('bannertabbed')); ?>
I have added dummy content to the field group on my front page. When I output get_post_meta() I can see that all my fields are there with the dummy content. I have also tried adding my ID to the get_field call but it’s still returning as NULL. I have another field group on the same page, which is also outside of the loop and it’s returning everything fine. Why is this one not? This is the export of the field group:
add_action( 'acf/include_fields', function() { if ( ! function_exists( 'acf_add_local_field_group' ) ) { return; } acf_add_local_field_group( array( 'key' => 'group_65133e0381c44', 'title' => 'bannertabbed', 'fields' => array( array( 'key' => 'field_65133e0545d2d', 'label' => 'banner1', 'name' => '', 'aria-label' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'placement' => 'top', 'endpoint' => 0, ), array( 'key' => 'field_65133e5345d2e', 'label' => 'image1', 'name' => 'image1', 'aria-label' => '', 'type' => 'image', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'array', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => '', 'preview_size' => 'medium', ), array( 'key' => 'field_65133e6445d2f', 'label' => 'title1', 'name' => 'title1', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), array( 'key' => 'field_65133e6d45d30', 'label' => 'text1', 'name' => 'text1', 'aria-label' => '', 'type' => 'textarea', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'rows' => '', 'placeholder' => '', 'new_lines' => '', ), array( 'key' => 'field_65133e8245d31', 'label' => 'link1', 'name' => 'link1', 'aria-label' => '', 'type' => 'link', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'url', ), array( 'key' => 'field_65133ed645d32', 'label' => 'tabtext1', 'name' => 'tabtext1', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), array( 'key' => 'field_651340a9b2b50', 'label' => 'banner2', 'name' => '', 'aria-label' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'placement' => 'top', 'endpoint' => 0, ), array( 'key' => 'field_651340edb2b52', 'label' => 'image2', 'name' => 'image2', 'aria-label' => '', 'type' => 'image', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'array', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => '', 'preview_size' => 'medium', ), array( 'key' => 'field_6513413ab2b54', 'label' => 'title2', 'name' => 'title2', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), array( 'key' => 'field_65134190b2b56', 'label' => 'text2', 'name' => 'text2', 'aria-label' => '', 'type' => 'textarea', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'rows' => '', 'placeholder' => '', 'new_lines' => '', ), array( 'key' => 'field_651341cfb2b59', 'label' => 'link2', 'name' => 'link2', 'aria-label' => '', 'type' => 'link', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'url', ), array( 'key' => 'field_65134240e4fab', 'label' => 'tabtext2', 'name' => 'tabtext2', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), array( 'key' => 'field_651340dbb2b51', 'label' => 'banner3', 'name' => '', 'aria-label' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'placement' => 'top', 'endpoint' => 0, ), array( 'key' => 'field_651340ffb2b53', 'label' => 'image3', 'name' => 'image3', 'aria-label' => '', 'type' => 'image', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'array', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => '', 'preview_size' => 'medium', ), array( 'key' => 'field_65134146b2b55', 'label' => 'title3', 'name' => 'title3', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), array( 'key' => 'field_65134195b2b57', 'label' => 'text3', 'name' => 'text3', 'aria-label' => '', 'type' => 'textarea', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'rows' => '', 'placeholder' => '', 'new_lines' => '', ), array( 'key' => 'field_651341cdb2b58', 'label' => 'link3', 'name' => 'link3', 'aria-label' => '', 'type' => 'link', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'return_format' => 'url', ), array( 'key' => 'field_65134243e4fac', 'label' => 'tabtext3', 'name' => 'tabtext3', 'aria-label' => '', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', ), ), 'location' => array( array( array( 'param' => 'page_type', 'operator' => '==', 'value' => 'front_page', ), ), ), 'menu_order' => 0, 'position' => 'normal', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => true, 'description' => '', 'show_in_rest' => 0, ) ); } );
I don’t know what else to check. It looks correct. It’s driving me crazy.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get_field always returns null even with content and page id set’ is closed to new replies.