Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to get a text-based navigation menu for the footer of my site. I'm using the wp_nav_menu() parameters as directed by Codex. He're a snippet of code (in footer.php):

<div id="footer">
    <?php wp_nav_menu(array('depth'=>1, 'after'=>'<span class="sep">|</span>')); ?><br />
    <div id="address">
        <p>...</p>
    </div>
    <div id="contactInfo">
        <p>...</p>
        <p>...</p>
    </div>
</div><!-- #footer -->

So, my goal is to make the menu look like Home | About | MorePages with only the root-level pages included.

The problem:

The after parameter is ignored! If I try before and items_wrap, along with other parameters, they are also ignored. I've been able to get after_link and before_link to work, as well as depth.

I've tried escaping things and not passing HTML, but neither helps.

I'm building based on the Sandbox theme, but nav-menu-template.php and nav-menu.php appear unchanged from the WP core.

How can I get these custom parameters to work?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

The reason for your not being able to use before and after is because when you're calling wp_nav_menu() with a default fallback of wp_page_menu(), which does not have a before and after arguments.

Refer to line 171: http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/nav-menu-template.php#L137

Apparently the menu you are trying to get does not exist (has no items) the !$menu is true. Make sure you have created a menu in Appearance > Menus and set it to a default one, or query for an existing one, or customize the fallback function, otherwise wp_page_menu will be called, simply listing all the pages.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.