• Resolved dmontesi

    (@dmontesi)


    Hi everyone,

    I uploaded my site from my localhost to a web server, and the menu got all messed up. I’ve been looking on other threads but haven’t found the exact same issue.

    Here’s the deal:
    I created my template and menu from scratch. My menu (now after uploading it on a live testing site) displays all links of pages even if they don’t belong to either menu. All links are displaying in both Header and Footer menus.

    This is how I registered my menus in my functions.php:

    // Navigation Menus
    register_nav_menus(array(
    ‘primary’ => __( ‘Primary Menu’),
    ‘footer’ => __( ‘Footer Menu’),
    ));

    Here’s what I put in the header.php:

    <nav class=”site-nav primary-menu”>

    <?php $args = array(‘theme_location’ => ‘primary’);?>

    <?php wp_nav_menu( $args ); ?>
    </nav>

    And the footer.php:

    <nav class=”site-nav”>
    <?php $args = array(‘theme_location’ => ‘footer’);?>
    <?php wp_nav_menu( $args ); ?>
    </nav>

    I would appreciate any help,

    Thanks,
    Dan.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try keeping PHP block together whenever possible like this:

    <?php
    $args = array('theme_location' => 'primary');
    wp_nav_menu( $args );
    ?>

    Not like this:

    <?php $args = array('theme_location' => 'primary');?> //starts and ends php
    <?php wp_nav_menu( $args ); ?> //starts and ends php

    That said, force a re-save of your menus. Just change one menu item title etc and save – and while there make sure the menu locations are set.

    And…you could, from example from above, do this (//are comments):

    <?php //did we start in php?
    echo '<nav class="site-nav primary-menu">';//single '' wrap as quotes inside
    $args = array('theme_location' => 'primary');
    wp_nav_menu( $args );
    echo "</nav>"; // "" wrap as no double quotes inside
    ?> //do we need to end php?

    Without comments:

    <?php echo '<nav class="site-nav primary-menu">';
    $args = array('theme_location' => 'primary');
    wp_nav_menu( $args );
    echo "</nav>"; ?>

    Now all in PHP.

    Your local host may not be running the type of PHP error checking your new remote server does.

    Thread Starter dmontesi

    (@dmontesi)

    @pioneer Valley Web Design:
    Thanks so much for your advice on php, and the clarity of your response. I’m still newbie with php. I’ll test it out, and let you know how it works.

    Thanks again!

    Thread Starter dmontesi

    (@dmontesi)

    Perfect!, this fixed my problem!. Thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Menu displaying ALL pages in header and footer’ is closed to new replies.