简体   繁体   中英

Left Sidebar on Wordpress won't create menu

I tried googling this, but not having much luck...

I have been able to create a menu using wordpress and entering this code in my header:

<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

And this in my scripts part:

function register_custom_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_custom_menu' );

But it seems that when trying to sort it, using the left side bar in the customize theme mode, it will not sort the menu nor will it remove any part of the menu that I add or remove using it.

From what I can tell it's just pulling my pages that I created within wordpress.

Keep in mind, this is a new theme I'm creating - my first theme. I have no PHP experience. Trying to learn as I go.

Picture of issue

I removed some of the names of the links for public view. I need to figure out how to also style this properly, but I've seen some other posts about it, so I'll review those later.

If someone can help me get this side menu to work with my current menu that would be great!

您是否尝试过通过外观->菜单来构建菜单?

In the Wordpress backend, go to "Design > Menus", create a new menu there, add all entries you want to have, give it a name and in the "positions" tab on that page, assign it to the defined position in your theme ( header-menu in your case). And disable the option to add all new pages/posts automatically.

If you try altering your wp_nav_menu call to the following (no parameters):

<?php wp_nav_menu(); ?>

It should fall back on the first non-empty menu. While you may want additional menus later/will likely want to customize your menu(s) more, this should help with troubleshooting as whatever initial menu you have created (is non-empty) is the menu being edited by the customize page.

From what I can tell it's just pulling my pages that I created within wordpress.

This likely relates to the setting "Automatically add new top-level pages to this menu" in the menu settings tab. This may be found under Appearance >> Menus, or under Customize >> Menus >> Clicking on the arrow to the right of your primary menu >> menu options (at the bottom of the resulting tab on the left).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM