0

我有一个带有侧边栏的 wordpress 站点,该站点以我下载的主题为主题。

在外观 > 菜单中,我创建了一个新菜单,然后将侧栏菜单下拉列表设置为新创建的菜单,但是当您访问网站时,它没有任何区别.. 旧菜单仍然存在...

在此处输入图像描述

所以我从主题中查看了代码编辑器,但我不知道如何更改它,以便它可以从我新创建的菜单中工作,我希望有人能够帮助我.. 这是 sidebar.php 代码和侧边栏-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' );
?>

边栏.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-->

任何帮助,将不胜感激

4

1 回答 1

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(array('menu' => ' Catalog '));中的值 这将调用您的菜单名为“目录”,主题声明您可以从后端更改所选菜单

于 2012-10-28T08:48:07.123 回答