我正在尝试将自定义菜单页面(在外观下)添加到自定义wordpress主题,但是我的钩子出了问题。我得到的错误是:
*警告:无法修改标题信息 - 已在/ home3 / keganqui / public_html /中发送的文件(在/home3/keganqui/public_html/optimus/wp-content/themes/optimus/functions.php:2中开始输出)第103行上的optimus / wp-admin / theme-editor.php *
我的主题选项出现在网站的每个页面上(不仅仅是后端)。由于某种原因,标签被剥离了所有内容,并且正文以
开头<body>
<div id="wrap">HTML FOR MY THEME OPTIONS</div>
<title>page title</title>
...all other info that should be in <head>
我不确定我是否做得很好解释,所以看看www.keganquimby.com/optimus(那个丑陋的灰盒子是我的主题选择)
答案 0 :(得分:1)
add_action('admin_init', 'theme_options_init');
add_action('admin_menu', 'theme_options_add_page');
function theme_options_init() {
register_setting('theme_options', 'mytheme_theme_options', 'theme_options_validate');
}
function theme_options_add_page() {
$page = add_theme_page(__('Theme Options', 'mytheme' ), __('Theme Options', 'mytheme'), 'edit_theme_options', 'theme_options', 'theme_options_do_page');
add_action('admin_print_styles-'.$page, 'theme_options_js');
}
function theme_options_js() {
// whatever js you need...
wp_enqueue_script('jquery-ui-core');
}
function theme_options_validate($input) {
$input['sometextarea'] = wp_filter_post_kses($input['sometextarea']);
return $input;
}
function theme_options_do_page() {
if (!isset($_REQUEST['settings-updated'])) {
$_REQUEST['settings-updated'] = false;
}
?><div>
your theme options page
</div><?php
}