Support

Account

Forum Replies Created

  • Yes, just like @elardael said. You would add this as a parameter in to acf_add_options_sub_page or acf_add_options_page.

    add_action('acf/init', function() {
    	if (function_exists('acf_add_options_sub_page')) {
    
    		acf_add_options_sub_page(array(
    			'post_id'     => 'unique_id',
    			'menu_title'   	 => 'Event Settings',
    			'parent_slug'    => 'edit.php?post_type=events',
    		));
    
    		acf_add_options_sub_page(array(
    			'post_id'     => 'another_unique_id',
    			'menu_title'   	 => 'Cookie Settings',
    			'parent_slug'    => 'edit.php?post_type=cookies',
    		));
    
    	}
    );

    This would allow you to be more certain and specific when getting fields from option pages. Rather than using get_field('field_name', 'options'); you can type get_field('field_name', 'unique_id'); and be certain that the field is from that specific options page.

    Now you can also have field names with the same name on different option pages, not possible if you don’t register a post_id.

    Also, as mentioned before you, can get all fields from an entire options page; get_fields('unique_id');

  • Make sure you have the Google Places API enabled on you key to get the autocomplete search to work. You also need billing on the account. You should see in your console what needs to be done on your Google Account.

  • In order to do this you must register your option pages with separate ID’s. There’s no mention of this in the ACF Docs but you can enter 'post_id' as a parameter when you use acf_add_options_sub_page or acf_add_options_page. Then you’ll be able to use get_fields('your_own_id') to only get the fields on that particular option page. Otherwise all option pages are registered with the same id: ‘option’.

    To see what is happening you can use the function acf_get_options_pages() to list all your registered option pages and see their parameters.

Viewing 3 posts - 1 through 3 (of 3 total)