2
因此,我對整個WordPress的事情都很陌生,但我仍然對HTML/CSS有經驗。我在WordPress的管理區域內創建了一個新菜單,但是當分配給主題時,它仍然無法正確顯示。如果我在這裏完全失明,但提前道歉,但PHP並不是我的強項。WordPress菜單已分配但未顯示
所以下面是有問題的代碼,與這裏的菜單是頭部段:
<div id="nav-primary" class="nav"><nav>
<?php if (is_user_logged_in()) {
wp_nav_menu(array('theme_location' => 'logged-in-menu')); /* if the visitor is logged in, this primary navigation will be displayed */
} else {
wp_nav_menu(array('theme_location' => 'header-menu')); /* if the visitor is NOT logged in, this primary navigation will be displayed. if a single menu should be displayed for both conditions, set the same menues to be displayed under both conditions through the Wordpress backend */
} ?>
</nav></div><!--#nav-primary-->
我知道「頭菜單」指向一個新的菜單我建立,但是它沒有顯示正確的。相反,它顯示了很多菜單項,當我設置的項目只有4個項目時。
任何人都可以擺脫這一切嗎?我真的很感謝一些幫助。
謝謝!
馬克
我剛剛意識到我沒有在外觀>菜單下選擇登錄菜單。現在顯示正常,但我在主菜單上方有一個小菜單。 在標題區域有兩種菜單嗎? –
是的,你可以添加你想要的,只需在功能中創建一個菜單,並將其添加到收聽文件。 –
好的,所以額外的菜單會在functions.php中是這樣的嗎? /*添加兩個自定義菜單*/function register_my_menus(){register_nav_menus(array('logged-in-top-menu'=> _('Logged in Top Menu'),'header-top-menu'=> _ ('Header Top Menu'))); } add_action('init','register_my_menus'); 我會將上面的代碼添加到functions.php中,然後在下面添加我想要的附加菜單出現的位置? ());}};}};}};}};}};}};其他{ \t wp_nav_menu(array('theme_location'=>'header-top-menu')); }?> –