向自定义页面(Add_SubMenu_Page)添加部分(Add_Setting_Section)不起作用

时间:2017-09-10 作者:Ali

我正在向子菜单页面添加一个部分,但除了一个带有三个隐藏字段的空表单外,其他内容都没有输出。

   <?php

function testTheme_add_admin_page() {
//add admin page
    add_menu_page(\'testTheme custom options\', \'Test Theme\', \'manage_options\', \'alecaddd_testTheme\', \'testTheme_create_page\', get_template_directory_uri() . \'/images/sunset-icon.png\', 110);

//add submenu pages
    add_submenu_page(\'alecaddd_testTheme\', \'General Settings\', \'General\', 
\'manage_options\', \'alecaddd_testTheme\', \'testTheme_create_page\');

//activate custom settings
    add_action(\'admin-init\', \'testTheme_custom_settings\');
}

add_action(\'admin_menu\', \'testTheme_add_admin_page\');
function testTheme_custom_settings() {
    register_setting(\'testTheme-settings-group\', \'first_name\');
    add_settings_section(\'testTheme-sidebar-options\', \'Sidebar Options\', 
\'testTheme_sidebar_options\', \'alecaddd_testTheme\');
}

function testTheme_sidebar_options() {
    echo "Sidebar Settings";
}

function testTheme_create_page() {

    require_once get_template_directory() . \'/inc/templates/testTheme-
admin.php\';
}

function testTheme_general_settings() {
//Add submenu page
}

function testTheme_settings_page() {

}
testTheme管理员。PHP代码

<form method="post" action="">
    <?php settings_fields(\'cleanblog-settings-group\'); ?>
    <?php do_settings_sections(\'alecaddd_cleanblog\'); ?>
</form>

1 个回复
SO网友:Kumar

add_action(\'admin-init\', \'testTheme_custom_settings\');.此处指定的操作错误。

将其更新为:add_action(\'admin_init\', \'testTheme_custom_settings\');

它应该会起作用。

结束

相关推荐

Virtual Pages plugins

我很难让插件正常工作Virtual Pages (WordPress插件可简化虚拟页面的创建)我确实进行了编辑,根据查询创建了一个循环。add_action( \'gm_virtual_pages\', function( $controller ) { /* Creating virtuals pages for companies */ $args = array( \'post_type\' => array(\'companies\',), \'post_status\'