WordPress beginner
Out of context: Reply #19
- Started
- Last post
- 19 Responses
- dee-dubs0
Got another WP question hoping someone can shed light on... google so far no joy.
I have menu which i have added some sub menu items. Id expect (and all WP tutorials examples show) the menu code to be along these lines:
<ul>
<li>menu item 1</li>
<li>menu item 2</li>
<li>menu item 3
<ul class="sub-menu">
<li>sub 1</li>
<li>sub2</li>
</ul>
</li>
<li>menu item 4</li>
</ul>but what im actually getting is:
<ul>
<li>menu item 1</li>
<li>menu item 2</li>
<li>menu item 3</li>
<ul class="sub-menu">
<li>sub 1</li>
<li>sub2</li>
</ul>
<li>menu item 4</li>
</ul>ie the sub menu is not within its parents li (like all the examples I have seen)
This is minimal custom theme I have made, do I need to add some function or something to get it to be where it should?
- use the built in menu functionality and it will work fine - https://codex.wordpr…fadein11
- I am... i thinkdee-dubs
- registering the nav
register_nav_menus(a...
'primary' => __( 'Main Navigation' ),dee-dubs - strange - it should be like you say. silly question but have you searched wordpress site?- answer for everything - or stackoverflow.fadein11
- Doh... i know whats causing the problem... not sure how to fix
i was using 'after' =>
in wp_nav_menu args and thats mucking it updee-dubs - what code are you using to display the menu in your template/header?fadein11
- $args = array(
'theme_location' => 'primary',
'after' => '<li class="navSpace"><p>/</p></li>');dee-dubs - wp_nav_menu( $args );dee-dubs
- use something like this (obv replace the relevant bits)
<?php wp_nav_menu( array(
'container' => 'div',fadein11 - 'container_class' => 'main-nav',
'fallback_cb' => 'responsive_fallback...
'theme_location' => 'header-menu'
) ); ?>fadein11 - if you don't have a responsive menu can leave that out.fadein11
- actually looks like you have that pretty much.fadein11
- thanks...tried it and still no dice... it is definatly the 'after' that is causing it... will see if I can remove it and create the same effect in pure CSSdee-dubs
- weird - never had that issue... hope you sort it.fadein11
- Any luck?bklyndroobeki