Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6496

    It would be truly awesome if your themes would have an option to use a different menu when logged in.

    As you already have Theme Locations for the Corona Template Menus it would require a small extension to this and would really help!

    In the mean time where is the correct place to add the php code for this

    #54406

    Hey,

    In your header.php file find

    <?php
    /*
    * display the main navigation menu
    * modify the output in your wordpress admin backend at appearance->menus
    */
    $args = array('theme_location'=>'avia2', 'fallback_cb' => '');
    wp_nav_menu($args);
    ?>

    Here you can add your “if logged in => … else …”

    #54407

    Thanks Chris,

    The idea was more to make it easier for those that don’t want to get their hands “dirty”.

    Although I am sure it would be a handy WP feature in general.

    Probably a simple hook for a plugin.

    #54408

    Getting Your Hands Dirty

    Actually they are not going to get very dirty, as I have found that you only require 2 simple edits.

    In functions.php

    Change…

    Code:
    /* Activate native wordpress navigation menu and register a menu location */
    add_theme_support(‘nav_menus’);
    $avia_config[‘nav_menus’] = array(‘avia’ => ‘Main Menu’, ‘avia2’=> ‘Sub Menu’);
    foreach($avia_config[‘nav_menus’] as $key => $value){ register_nav_menu($key, THEMENAME.’ ‘.$value); }

    To…

    Code:
    /* Activate native wordpress navigation menu and register a menu location */
    add_theme_support(‘nav_menus’);
    $avia_config[‘nav_menus’] = array(‘avia’ => ‘Main Menu’, ‘avia2’=> ‘Sub Menu’, ‘avia3’=> ‘Members Menu’);
    foreach($avia_config[‘nav_menus’] as $key => $value){ register_nav_menu($key, THEMENAME.’ ‘.$value); }

    Then in header.php

    Change…

    Code:
    /*
    * display the main navigation menu
    * check if a description for submenu items was added and change the menu class accordingly
    * modify the output in your wordpress admin backend at appearance->menus
    */
    $args = array( ‘echo’=> false,
    ‘fallback_cb’ => ‘avia_fallback_menu’,
    ‘theme_location’ => ‘avia’,
    ‘menu_class’ => ‘menu’,
    ‘walker’ => new avia_description_walker()
    );

    To…

    Code:
    /*
    * display the main navigation menu
    * check if a description for submenu items was added and change the menu class accordingly
    * modify the output in your wordpress admin backend at appearance->menus
    */
    if ( is_user_logged_in() ) {
    $args = array( ‘echo’=> false,
    ‘fallback_cb’ => ‘avia_fallback_menu’,
    ‘theme_location’ => ‘avia3′,
    ‘menu_class’ => ‘menu’,
    ‘walker’ => new avia_description_walker()
    );
    } else {
    $args = array( ‘echo’=> false,
    ‘fallback_cb’ => ‘avia_fallback_menu’,
    ‘theme_location’ => ‘avia’,
    ‘menu_class’ => ‘menu’,
    ‘walker’ => new avia_description_walker()
    );
    }

    You will then find a 3rd supported Corona Menu within the WordPress “Appearance – Menus”. and you can create a menu and select it from the new drop down list as normal.

    #54409

    wow, thanks.

    And you haven’t such a great idea for a drop-down menu for submenu? ;-)

    #54410

    Thanks for sharing your solution, it’s great to see when people come up with things like this and share it with the community!

    #54411

    This post was super helpful! I applied the changes to the “Flashlight” theme. The only difference was with the Flashlight theme you have to make the changes to the sidebar.php file instead of the header.php file because of the way the theme is designed.

    #54412

    Hi!

    Glad that the tutorial helped you :)

    Regards,

    Peter

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Dynamic Logged in/out Menus’ is closed to new replies.