Wordpress には、このサンプル テーマ オプション ページがあり、外観メニュー ページの下に表示されますが、カスタム ページ (ライブ ショット) の下に表示したいです。で何かを変更する必要があると考えていadd_settings_section( $id, $title, $callback, $page )
ますが、試してみましたが、オプション ページの情報が消えるだけです。
function liveshot_server_theme_options_init() {
register_setting(
'liveshot_server_options', // Options group, see settings_fields() call in liveshot_server_theme_options_render_page()
'liveshot_server_theme_options', // Database option, see liveshot_server_get_theme_options()
'liveshot_server_theme_options_validate' // The sanitization callback, see liveshot_server_theme_options_validate()
);
// Register our settings field group
add_settings_section(
'general', // Unique identifier for the settings section
'', // Section title (we don't want one)
'__return_false', // Section callback (we don't want anything)
'theme_options' // Menu slug, used to uniquely identify the page; see liveshot_server_theme_options_add_page()
);
// Register our individual settings fields
add_settings_field(
'sample_checkbox', // Unique identifier for the field for this section
__( 'Sample Checkbox', '_s' ), // Setting field label
'liveshot_server_settings_field_sample_checkbox', // Function that renders the settings field
'theme_options', // Menu slug, used to uniquely identify the page; see liveshot_server_theme_options_add_page()
'general' // Settings section. Same as the first argument in the add_settings_section() above
);
add_settings_field( 'sample_text_input', __( 'Sample Text Input', '_s' ), 'liveshot_server_settings_field_sample_text_input', 'theme_options', 'general' );
add_settings_field( 'sample_select_options', __( 'Sample Select Options', '_s' ), 'liveshot_server_settings_field_sample_select_options', 'theme_options', 'general' );
add_settings_field( 'sample_radio_buttons', __( 'Sample Radio Buttons', '_s' ), 'liveshot_server_settings_field_sample_radio_buttons', 'theme_options', 'general' );
add_settings_field( 'sample_textarea', __( 'Sample Textarea', '_s' ), 'liveshot_server_settings_field_sample_textarea', 'theme_options', 'general' );
}
add_action( 'admin_init', 'liveshot_server_theme_options_init' );
/**
* Change the capability required to save the 'liveshot_server_options' options group.
*
* @see liveshot_server_theme_options_init() First parameter to register_setting() is the name of the options group.
* @see liveshot_server_theme_options_add_page() The edit_theme_options capability is used for viewing the page.
*
* @param string $capability The capability used for the page, which is manage_options by default.
* @return string The capability to actually use.
*/
function liveshot_server_option_page_capability( $capability ) {
return 'edit_theme_options';
}
add_filter( 'option_page_capability_liveshot_server_options', 'liveshot_server_option_page_capability' );
/**
* Add our theme options page to the admin menu.
*
* This function is attached to the admin_menu action hook.
*
* @since _s 1.0
*/
function liveshot_server_theme_options_add_page() {
$theme_page = add_theme_page(
__( 'Theme Options', '_s' ), // Name of page
__( 'Theme Options', '_s' ), // Label in menu
'edit_theme_options', // Capability required
'theme_options', // Menu slug, used to uniquely identify the page
'liveshot_server_theme_options_render_page' // Function that renders the options page
);
}
add_action( 'admin_menu', 'liveshot_server_theme_options_add_page' );
/**
* Returns an array of sample select options registered for _s.
*
* @since _s 1.0
*/