试图添加一个自定义菜单页面到我的WordPress主题
问题描述:
我想添加一个自定义菜单页面(在外观下)到一个自定义的WordPress主题,但是我的钩子出了问题。我得到的错误是:试图添加一个自定义菜单页面到我的WordPress主题
*警告:无法修改标头信息 - 标头已经发送(输出开始于/home3/keganqui/public_html/optimus/wp-content/themes/optimus/functions.php:2 )in /home3/keganqui/public_html/optimus/wp-admin/theme-editor.php on line 103 *
我的主题选项出现在每一个页面上,全网站(不只是后端)。出于某种原因,该标签被剥夺的所有内容和体
<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(即丑陋的灰色盒子是我的主题选项)
答
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
}
+0
我如何获得设置保存?出于某种原因,格式是正确的,但是当我改变一个设置它不是保存。 – 2012-02-01 13:23:22
在第2行检查'wp-content/themes/optimus/functions.php'。有一些输出到浏览器,它不应该在那里。 – Cheery 2012-02-01 02:36:17
下面的回应工作:) – 2012-02-01 02:45:03