Support

Account

Home Forums Add-ons Options Page Discrepancy between documentation/functionality of acf_add_options_sub_page()

Discrepancy between documentation/functionality of acf_add_options_sub_page()

  • I think there might be a bug/mixup in the options addon. The documentation states that a “title” argument will set the options page title and a “menu” argument will set the text of the menu item.

    However, this code generates a title of “Mapping” and a menu item of “Mapping Settings”:

    if( function_exists('acf_add_options_sub_page') )
    {
        acf_add_options_sub_page(array(
            'title' => 'Mapping Settings',
            'menu' => 'Mapping',
            'parent' => 'options-general.php',
            'capability' => 'manage_options'
        ));
    }
  • Also just noticed that adding a ‘slug’ argument goofs up the field group rules. In the example provided above my field group rule says “Show this field group if Options Page is equal to Mapping” but then upon visiting the generated options page I get the “No Custom Field Group found for the options page.” message.

    I’m new to this addon so could be doing something wrong but something seems to be acting up.

  • Hi @denny

    Thanks for the feedback. I’ll take a look at the title / menu issue, however I don’t fully comprehend the issue with location rules.

    Perhaps what has happened is this:
    1. You create an options page with default slug
    2. You create a field group and attach it to that options page
    3. You change the options page slug
    4. Now the field group does not appear

    If the above is correct then this is perfectly normal. The location rules are saved to the slug, if you change the slug, it will not find the matching location rule.

    You will need to update the field group location rule to get it working again

  • I’ve confirmed the following:

    1. Creating an options page, then changing the title/menu name options does break the page<->field group link. Revisiting the field group and updating it re-associates things correctly.

    2. Adding a ‘slug’ argument breaks things completely. The behavior in #1 would be expected, however upon updating the field group those fields still do not show up in the options page. Even if I add a ‘slug’ argument before creating a new field group there still seems to be no association between the options page and field group.

  • Hi @denny

    Can you please paste the slug you are using. Actually, can you paste the whole function + args so I can recreate the issue?

    Thanks
    E

  • This is the code that exhibits both issues: the title/menu switcharoo and the slug breaking my options page fields.

    <?php 
    
    if( function_exists('acf_add_options_sub_page') )
    {
      acf_add_options_sub_page(array(
        'title' => 'Mapping',
        'menu' => 'Mapping Settings',
        'parent' => 'options-general.php',
        'slug' => 'mapping',
        'capability' => 'manage_options'
      ));
    }
    
    ?>
  • Awesome

    Thanks for the code, I’ll test it out.

    Cheers
    E

  • Thanks Elliot. No hurry, neither of the issues are show stoppers, just wanted to point out my experience in case it will help improve the functionality.

    Really appreciate what you’ve done with this plugin, it’s completely revolutionized the way I use WordPress.

  • Yes, I’m seeing this too.

    When I use ‘parent’ =>’options-general.php’ with similar code to that listed abvoe, it makes the sub-page “footer” show up under the general wordpress settings menu under permalinks.

    If I use alternative parent, for example:

    	if( function_exists('acf_add_options_sub_page') )
    	{
        acf_add_options_sub_page(array(
            'title' => 'Footer',
            'parent' => 'acf-options',
        ));
    	}

    It breaks the options page altogegher. Specifically, i notice it removes the default options page as a choice in the field group rules locations.

    Here’s the entire code I’m using in a child theme functions.php file:

    add_action('init', 'os_child_theme_options');
    
    	function os_child_theme_options (){
    	
    	if( function_exists('acf_set_options_page_menu') )
    	{
    	    acf_set_options_page_menu( __('Theme Options') );
    	}
    
    	if( function_exists('acf_set_options_page_title') )
    	{
    	    acf_set_options_page_title( __('Theme Options') );
    	}	
    	
    	if( function_exists('acf_add_options_sub_page') )
    	{
        acf_add_options_sub_page(array(
            'title' => 'Footer',
            'parent' => 'acf-options',
        ));
    	}	
    	
    }
  • Went back to the other code you suggest:

    add_filter('acf/options_page/settings', 'os_acf_options_page_settings');
    
    	function os_acf_options_page_settings( $settings )	{
    		$settings['title'] = 'Theme Options';
    		$settings['pages'] = array('Header', 'Sidebar', 'Footer');
    	 
    		return $settings;
    	}

    and it works fine, but using the previous code posted with title and slugs still not working.

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

The topic ‘Discrepancy between documentation/functionality of acf_add_options_sub_page()’ is closed to new replies.