使用bootstrap创建wordpress主题,并在注册菜单区

时间:2016-05-29 01:58:36

标签: php wordpress twitter-bootstrap wordpress-theming

我正在尝试使用bootstrap从头创建一个WordPress主题 我正在使用我从GitHub获得的文件,并从中实现了很多东西。你可以在Github找到它。名字是 : twittem /可湿性粉剂引导-navwalker

现在我正在创建菜单/注册菜单区域,并使用了以下代码:

<?php 
require_once('wp_bootstrap_navwalker.php');

//theme support
function theme_setup(){
//nav menu
    register_nav_menus(array(
      'primary' => __('Primary Menu')
    ));
}
//for the above function to work we need tocreate an addaction function, which lets us choose a hook to run it
//the one we want is aftr set up theme

  add_action('after_setup_theme','wpb_theme_setup');

执行此操作后,菜单会显示,但上面有一个错误:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wpb_theme_setup' not found or invalid function name in C:\wamp\www\wordpress-bootstrap\bootstrap\wp-includes\plugin.php on line525
Call Stack
#   Time    Memory  Function    Location
1   0.0005  241464  {main}( )   ..\index.php:0
2   0.0007  244632  require( 'C:\wamp\www\wordpress-bootstrap\bootstrap\wp-blog-header.php' )   ..\index.php:17
3   0.0011  264688  require_once( 'C:\wamp\www\wordpress-bootstrap\bootstrap\wp-load.php' ) ..\wp-blog-header.php:13
4   0.0016  275768  require_once( 'C:\wamp\www\wordpress-bootstrap\bootstrap\wp-config.php' )   ..\wp-load.php:37
5   0.0027  402232  require_once( 'C:\wamp\www\wordpress-bootstrap\bootstrap\wp-settings.php' ) ..\wp-config.php:89
6   0.3356  21979856    do_action( )    ..\wp-settings.php:377
7   0.3357  21981408    call_user_func_array:{C:\wamp\www\wordpress-bootstrap\bootstrap\wp-includes\plugin.php:525} ( )

我不知道如何解决此错误或如何处理它。有人可以请帮助。

1 个答案:

答案 0 :(得分:2)

function theme_setup(){更改为function wpb_theme_setup(){

钩子add_action('after_setup_theme','theme_setup');试图调用一个不存在的函数。