• Hi,
    Total newbie, so bear with me!
    Theme used is twentyeleven, with Child Theme.
    Site has area for Public and one for Members, which is by login i.e “Protected”. Menus registered in Child Theme functions.php.
    I have followed similar topics but conditional statement in header.php fails. i.e ‘if’ works (tried switching it) ‘else’ never actions.

    ” <nav id=”access” role=”navigation”>
    <h3 class=”assistive-text”><?php _e( ‘Main menu’, ‘twentyeleven’ ); ?></h3>
    …………………etc
    <?php
    if ( !post_password_required() ) {
    wp_nav_menu( array( ‘theme_location’ => ‘members-menu’,’menu_id’ => ‘menu’) );
    } else {
    wp_nav_menu(array(‘theme_location’ => ‘public-menu’,’menu_id’ => ‘menu’) );
    }
    ?>
    </nav>

    I have also tried conditional
    “if ( is_user_logged_in() ) { “etc

    Any pointers as to what I have missed would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Looking at the codex there is no default for the $post, so you need to specify it.

    post_password_required( $post );

    I’m not sure why you’re negating the post_password_required() argument. If post_password_required returns true, don’t you want to display the member’s menu?

    Thread Starter ellastonepaul

    (@ellastonepaul)

    Thanks!…but it still doesn’t work!

    First. Don’t understand ref to “negating…argument”. As I see it IF a password is required THEN use Members Menu…ELSE use Public Menu?

    Anyway further puzzle. Using Theme (2011) Customiser, Navigation section. Three parts, Primary, Public Menu, Members Menu each offering dropdown menu of Public or Members. If you toggle the Public Menu box between Public and Members options the Nav Bar DOES change! As a further check, reversing the menus in the conditional clause and it is then similar in Members Menu box.
    Does not make any difference whether the page is “protected”, or not.

    Is there something elsewhere that is in conflict?

    Sorry to drag this out (and I have spent hours on this)…but I guess I will learn a lot if I ever get a solution!

    You are negating the if clause by including the exclamation mark.

    if ( !post_password_required() ) {

    That is saying “if not post_password_required is true”, in other words, if the post_password_required is false.

    Then if that condition is met, you display the member menu.

    I don’t think you want that exclamation mark there.

    Thread Starter ellastonepaul

    (@ellastonepaul)

    Thanks Matt.

    Copied from somewhere…but now I know what it means!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Alternative Menus in header’ is closed to new replies.