我是wordpress的新手,我正在为wordpress网站创建一个新主题,所以我在functions.php文件中写了一些函数。但由于该代码,管理面板未加载。每当我尝试登录管理面板时,它都显示空白页面。有谁可以请检查我的代码,让我知道是否有任何错误。 下面是我的functions.php文件代码
<?php
//Add support for WordPress 3.0's custom menus
add_action( 'init', 'register_my_menu' );
//Register area for custom menu
function register_my_menu() {
register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
register_nav_menu( 'secondary-menu', __( 'secondary Menu' ) );
}
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'menu1' ),
'secondary' => __( 'Secondary Menu', 'menu2'),
) );
//Gets post cat slug and looks for single-[cat slug].php and applies it
add_filter('single_template', create_function(
'$the_template',
'foreach( (array) get_the_category() as $cat ) {
if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
return $the_template;' )
);
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
?>
提前致谢
答案 0 :(得分:0)
看看这些:
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'menu1' ),
'secondary' => __( 'Secondary Menu', 'menu2') // get rid of trailing comma
) );
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1',
'description' => '', // added
'class' => '', // added
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>' // get rid of trailing comma
) );
}
add_action( 'init', 'register_my_menu' ); // call after function declaration, not before
add_action( 'widgets_init', 'arphabet_widgets_init' );