我第一次制作我自己的自定义WordPress主题,并且在尝试注册菜单时遇到了麻烦。Wordpress不会允许我们注册菜单
我跟着教程在http://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tutorial-2nd-edition/打造的主题,看它在http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus但无论我做什么登记,因为我没有看到菜单项添加到菜单都不行代码在wp-admin中。 这是我在注册它们的功能:
if (! function_exists('eastmids_setup')):
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* @since eastmids 1.0
*/
function eastmids_setup() {
/**
* Custom template tags for this theme.
*/
require(get_template_directory() . '/inc/template-tags.php');
/**
* Custom functions that act independently of the theme templates
*/
require(get_template_directory() . '/inc/tweaks.php');
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on eastmids, use a find and replace
* to change 'eastmids' to the name of your theme in all the template files
*/
load_theme_textdomain('eastmids', get_template_directory() . '/languages');
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support('automatic-feed-links');
/**
* Enable support for the Aside Post Format
*/
add_theme_support('post-formats', array('aside'));
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus(array(
'primary' => __('Primary Menu'),
));
}
endif; // eastmids_setup
add_action('after_setup_theme', 'eastmids_setup');
这里是我如何使用它:
<nav role="navigation" class="site-navigation main-navigation">
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>
</nav>
什么是显示的却是包含首页,然后我的网页的UL标签。
看到因为我无法看到wp-admin中的菜单我假设注册表失败。
任何人都可以帮忙吗?
啊我看到了,我没有意识到'主'名是wp_nav_menu调用位置的句柄。 我认为这是当我注册菜单时,它会显示为一个菜单添加到wp-admin的项目,但是当我去那里创建一个新的菜单,我发现你的意思是在“主题位置” –