Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Set Menu locatin in wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 114
    Comment on it

    Hello reader's, In this post we discussed about "How to set Menu location in wordpress".

    You can use the below code for creating menu and set their location, when you import data file in xml.
    You can put this code into functions.php file

        <!--?php
        /* Add Menu */
    
    add_action( 'after_setup_theme', 'pinboard_setup' );
    
    if ( ! function_exists( 'pinboard_setup' ) ):
    function pinboard_setup()
    {
        add_theme_support( 'post-thumbnails' );
    
    register_nav_menus( array(
        'primary'       =&amp;gt; __( 'Primary Navigation', 'pinboard' ),
        'secondary'     =&amp;gt; __( 'Secondary Navigation', 'pinboard' ),
    
    ) );
    
    
    }
    endif;
    
    **
     * Set Menu location.
     * Set with menu id
     * Default Set
     */
    
    $menus = wp_get_nav_menus();
    $setMenu = get_theme_mod('nav_menu_locations');
    
    for( $mi=0;$mi&lt;count($menus);$mi++ ) {
    
    if( $menus[$mi]-&amp;gt;name == 'Header Menu' ) {
        $menu_id = trim( $menus[$mi]-&amp;gt;term_id );
        $setMenu['primary'] = $menu_id;
        set_theme_mod('nav_menu_locations', $setMenu);
    
    }
     elseif( $menus[$mi]-&amp;gt;name == 'bottom menu' ) {
    
      $setMenu['secondary'] = $menus[$mi]-&amp;gt;term_id;
      set_theme_mod('nav_menu_locations', $setMenu);
     }
    
    
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: