Home Forums Add-ons Options Page Get all fields from option page Reply To: Get all fields from option page

  • 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')) {
    			'post_id'     => 'unique_id',
    			'menu_title'   	 => 'Event Settings',
    			'parent_slug'    => 'edit.php?post_type=events',
    			'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');