我有一个带有侧边栏的wordpress网站,该侧边栏是我下载的主题的主题。
外观>菜单我创建了一个新菜单,然后我将侧栏菜单下拉列表设置为新创建的菜单,但是当你访问网站时它没有任何区别......旧的菜单仍然存在......
所以我从主题看了代码编辑器,我无法弄清楚如何改变它,所以它可以从我新创建的菜单中运行,我希望有人可以帮助我...这就是sidebar.php代码和sidebar-init.php
侧边栏的init.php
<?php
function elegance_widgets_init() {
// Header Widget
// Location: right after the navigation
register_sidebar(array(
'name' => 'Header',
'id' => 'header-sidebar',
'description' => __( 'Located at the top of pages.'),
'before_widget' => '<div id="%1$s" class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Sidebar Widget
// Location: the sidebar
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'main-sidebar',
'description' => __( 'Located at the right side of pages.'),
'before_widget' => '<div id="%1$s" class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Contact Form Widget
// Location: Contacts page
register_sidebar(array(
'name' => 'Contact Form',
'id' => 'contact_form',
'description' => __( 'Located at the left side of Contacts page.'),
'before_widget' => '<div id="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Address Widget
// Location: Contacts page
register_sidebar(array(
'name' => 'Address',
'id' => 'address',
'description' => __( 'Located at the right side of Contacts page.'),
'before_widget' => '<div id="%1$s" class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Footer Widget Area
// Location: at the top of the footer, above the copyright
register_sidebar(array(
'name' => 'First footer widget area',
'id' => 'first-footer-widget-area',
'description' => __( 'Located at the bottom of pages.'),
'before_widget' => '<div id="%1$s" class="widget-area">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
// Footer Widget Area
// Location: at the top of the footer, above the copyright
register_sidebar(array(
'name' => 'Second footer widget area',
'id' => 'second-footer-widget-area',
'description' => __( 'Located at the bottom of pages.'),
'before_widget' => '<div id="%1$s" class="widget-area">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
// Footer Widget Area
// Location: at the top of the footer, above the copyright
register_sidebar(array(
'name' => 'Third footer widget area',
'id' => 'third-footer-widget-area',
'description' => __( 'Located at the bottom of pages.'),
'before_widget' => '<div id="%1$s" class="widget-area">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
// Footer Widget Area
// Location: at the top of the footer, above the copyright
register_sidebar(array(
'name' => 'Fourth footer widget area',
'id' => 'fourth-footer-widget-area',
'description' => __( 'Located at the bottom of pages.'),
'before_widget' => '<div id="%1$s" class="widget-area">',
'after_widget' => '</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
));
}
/** Register sidebars by running elegance_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'elegance_widgets_init' );
?>
的sidebar.php
<aside id="sidebar" class="grid_6 omega">
<?php if ( ! dynamic_sidebar( 'Sidebar' )) : ?>
<div id="sidebar-nav" class="widget menu">
<h3>Navigation</h3>
<?php wp_nav_menu( array('menu' => 'Sidebar Menu' )); ?> <!-- editable within the Wordpress backend -->
</div>
<?php endif; ?>
</aside><!--sidebar-->
任何帮助将不胜感激
答案 0 :(得分:1)
<div id="sidebar-nav" class="widget menu">
<h3>Navigation</h3>
<?php wp_nav_menu( array('menu' => 'Catalogue' )); ?> <!-- editable within the Wordpress backend -->
</div>
只需更改wp_nav_menu中的值(数组('menu'=&gt;'目录'));这将调用名为“目录”的菜单,主题表明您可以从后端更改所选菜单