• silvanasono

    (@silvanasono)


    I have experienced the following issue.
    I have registered a primary menu in functions.php, then i put the code in the header and assigned specific classes to the container and the menu_class. When i loaded my page I saw a list of my pages but without any styling (that was already in the style.css) and so I have discovered that the classes were not been assigned to the div and ul.
    Practically, by default, these classes are not assigned unless I go in the admin panel, in the Menu section and assigned a menu to the menu created in functions.php. BUT by default a menu is created with the list of pages.

    So I think this is an anomalous behaviour that I wanted to notify to you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Which theme is this regarding?

    Thread Starter silvanasono

    (@silvanasono)

    Is it relevant?
    It is a self-made theme. But anyway, i have described the process. I think nothing was missing.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Does the exact same thing happen on a default theme (like Twenty Thirteen)? If not, then the kind of problem is endemic to your theme, and we’d have to look at the code to help solve it.

    Thread Starter silvanasono

    (@silvanasono)

    I read the code and trapped the point. It is here, line 264 of nav-menu-template.php:

    if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) )
    		&& $args->fallback_cb && is_callable( $args->fallback_cb ) )
    			return call_user_func( $args->fallback_cb, (array) $args );

    It stops there. If I do not assign a location in the Menu section of Admin Panel, by default the pages are showed by without any styling (because classes are not assigned).
    Now I had also assigned the location in the wp_nav_menu function:

    wp_nav_menu( array(
                      'container' => 'div',
                      'container_class' => 'grid_12',
                      'menu_class' => 'nav',
                      'theme_location' => 'primary' ) ); ?>

    that is the same of the register, primary:

    register_nav_menus( array(
                    'primary' => __( 'Primary Navigation', 'silvy2013' ),
            ) );

    (it is the same code of the Function Reference register_nav_menus( array( $location => $description ) );).

    So, maybe I have mistaken something, you can see for yourself.
    Of course, in the moment I assign a location in the Menu section, the problem is solved. Just wanted to know if there is a fault.
    Thank you

    Thread Starter silvanasono

    (@silvanasono)

    Furthermore, what I assign as menu_class is assigned to the container, I mean to the div not to the ul, like this:

    <div class="nav"><ul><li class="page_item

    it should be:

    <div class="grid_12"><ul class="nav"><li class="page_item

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Anomalous Behavior of Default Menu’ is closed to new replies.