Support

Account

Home Forums General Issues ACF in Theme not working properly Reply To: ACF in Theme not working properly

  • I found a bug in my framework. Now it’s working better.

    But I have to check something, just tell me if this is expected. I installed ACF and Options Page as a plugin to test and this is in functions.php theme.

    acf_add_options_sub_page(array(
    	'title' => 'Test',
    	'slug' => 'acf-options-module-test',
    	'parent' => 'options-general.php',
    	'capability' => 'manage_options'
    ));
    
    register_field_group(array (
    	'id' => 'acf_module_test_options',
    	'title' => 'Module Test',
    	'fields' => array (
    		array (
    			'key' => 'field_module_test_value',
    			'label' => 'Test',
    			'name' => 'module_test_value',
    			'type' => 'text',
    			'default_value' => 'default value',
    		)
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'options_page',
    				'operator' => '==',
    				'value' => 'acf-options-module-test',
    				'order_no' => 0,
    				'group_no' => 0,
    			),
    		),
    	),
    	'options' => array (
    		'position' => 'normal',
    		'layout' => 'no_box',
    		'hide_on_screen' => array (
    		),
    	),
    	'menu_order' => 0,
    ));
    
    function get_value() {
    	var_dump(get_field('module_test_value', 'option'));
    }
    
    get_value(); // don't get value
    add_action('init', 'get_value'); // get value