我最近开始研究WordPress主题,并发现了这个实用程序。我目前正在使用WordPress 4.7.4。我对代码做了以下修改,
在功能中。PHP;
function mytheme_setup(){
register_nav_menus( array(
\'side\' => __( \'Side Menu\', \'mytheme\' ),
\'social\' => __( \'Social Links Menu\', \'mytheme\' ),
) );
$starter_content = array(
// Set up nav menus for each of the two areas registered in the theme.
\'nav_menu\' => array(
// Assign a menu to the "side" location.
\'side\' => array(
\'name\' => __( \'Side Menu\', \'mytheme\' ),
\'items\' => array(
\'link_recent\' => array(
\'title\' => _x( \'Recent Articles\', \'Theme starter content\' ),
\'url\' => site_url( \'/#recent-articles\' ),
),
\'link_about\' => array(
\'title\' => _x( \'About Us\', \'Theme starter content\' ),
\'url\' => site_url( \'/#about-us\' ),
),
\'link_contact\' => array(
\'title\' => _x( \'Contact\', \'Theme starter content\' ),
\'url\' => site_url( \'/#contact-us\' ),
),
),
),
// Assign a menu to the "social" location.
\'social\' => array(
\'name\' => __( \'Social Links Menu\', \'mytheme\' ),
\'items\' => array(
\'link_facebook\',
\'link_twitter\',
\'link_instagram\',
\'link_youtube\',
),
),
),
);
$starter_content = apply_filters( \'mytheme_starter_content\', $starter_content );
add_theme_support(\'starter-content\', $starter_content);
}
add_action( \'after_setup_theme\', \'mytheme_setup\' );
而且,在头版。PHP,
<?php if ( has_nav_menu( \'side\' ) ) : ?>
<div class="navigation-side">
<nav id="site-navigation" class="main-navigation" role="navigation">
<?php
wp_nav_menu( array(
\'theme_location\' => \'side\',
));
?>
</nav>
</div><!-- .navigation-side -->
<?php endif; ?>
但是,我仍然找不到任何关于我的主题的入门内容菜单。