• Hi and thanks in advance.

    I’m having trouble getting at least one child menu from a dropdown in the top nav menu.

    ENVIRONMENT: Latest WordPress version, Underscore_s theme as starter, HTML5 laid on top implementing Bootstrap 4 and Material Design style and structure, WP Bootstrap Navwalker Version: 4.3.0.

    ISSUE: I am having trouble getting a child menu (or 2nd child) from the dropdown in the top Nav-bar. Also I can’t seem to add styling to the dropdown that I do have working (separate issue?).

    I suspect that there is something fundamental that I am missing or have done incorrectly in setting up. The Navwalker script should allow for at least one child from all that I have read. (I know, bootstrap-4 does not natively provide child dropdown support, therefor the updated Navwalker). I suspect that the child dropdown and styling issue, might be interconnected. Thats why I’m looking at basics. Also, I understand that in the WP Admin > Menus area I have to move a page to a child position in the structure / hierarchy. When I do so however, I get nothing for that child.

    Heres what I have:

    In WP Admin > Menus, my “Primary Menu” is named: “asato-music”.
    In _s “functions.php” the first registration of a menu looks like this:

    // This theme uses wp_nav_menu() in one location.
    	register_nav_menus(
    		array(
    		'asato-music' => esc_html__( 'Primary', 'asato_s' ),
    	)
    );

    Later in “functions.php” I added the Navwalker script:

    /**
     * BOOTSTRAP Custom Navigation Walker - bootstrap menu in wordpress
     * For documentation see:
     * https://github.com/wp-bootstrap/wp-bootstrap-navwalker
     */
    /**
     * Register Custom Navigation Walker
     */
    function register_navwalker(){
    	require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
    }
    add_action( 'after_setup_theme', 'register_navwalker' );
    
    /**
     * If you encounter errors with the above code use a check like this to return clean errors to help diagnose the problem.
     */
    
    if ( ! file_exists( get_template_directory() . '/class-wp-bootstrap-navwalker.php' ) ) {
        // File does not exist... return an error.
        return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
    } else {
        // File exists... require it.
        require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php';
    }
    
    /**
     * You will also need to declare a new menu in your functions.php file if one doesn't already exist.
     */
    register_nav_menus( array(
        'asato-music' => __( 'Primary Menu', 'asato_s' ),
    ) );

    Finally in “class-wp-bootstrap-navwalker.php” on line 366, I added the required theme name as follows in the two instances:

    esc_attr__( 'Add a menu', 'asato_s' ) . '">' . esc_html__( 'Add a menu', 'asato_s' )

    So I’m wondering if I have mislabeled something which is preventing the child dropdown, OR if there is another issue.

    Thanks again

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator t-p

    (@t-p)

    Since you use a commercial theme or plugin and need support, please go to their official support channel. In order to be good stewards of the WordPress community, and encourage innovation and progress, we feel it’s important to direct people to those official locations.

    https://underscores.me/

    Forum volunteers are also not given access to commercial products, so they would not know why your commercial theme or plugin is not working properly. This is one other reason why volunteers forward you to the commercial product’s vendors. The vendors are responsible for supporting their commercial product. Commercial products are not supported in these forums.

    Thread Starter clsimco

    (@clsimco)

    OK thanks….. I thought _s was a framework for building a theme, not a theme.

    Your direction is much appreciated

    ;^)

    Moderator t-p

    (@t-p)

    You are welcome 🙂

    Thread Starter clsimco

    (@clsimco)

    BTW….. not much of a forum that I can find at https://underscores.me/ or GitHub for that matter….. Would you have a more specific place that I should post the question, of a different forum here? I’m trying to learn to make themes.

    Moderator t-p

    (@t-p)

    Latest WordPress version, Underscore_s theme as starter, …

    There is NO Underscore, or Underscores, or Underscore_s theme listed in the in the wordpress.org/themes/ directory, as far as I can see.

    Hence, sorry, I could not find a dedicated support forum for it here.

    • This reply was modified 5 years, 4 months ago by t-p.
    • This reply was modified 5 years, 4 months ago by t-p.
    Thread Starter clsimco

    (@clsimco)

    Ok. That’s interesting. Earlier, I posted a question about an issue I was having and got this reply from one of the moderators here. That’s why set off in this direction, and, have made quite a lot of progress in learning theme creation.

    Where I am having an issue, as I wrote earlier, is in trying to eliminate sources where I may have made mistakes, that might be preventing WordPress from allowing dropdown children and styling of the menu.

    Your patience is appreciated.

    Moderator t-p

    (@t-p)

    Thread Starter clsimco

    (@clsimco)

    Thanks for the links. I also found this one among many here on the WordPress.org site

    https://developer.wordpress.org/themes/getting-started/theme-development-examples/

    just in case you are interested.

    Anyway I’ll try posting in another forum as well. I do appreciate your time and attention.

    Best to you in the new year!

    Moderator t-p

    (@t-p)

    Here is also this general theme handbook, not particular to the Underscore: Theme Handbook

    Happy New Year 🙂

    Moderator bcworkz

    (@bcworkz)

    Hiya clsimco,

    Since _s is a starter theme meant for developers to build upon and enhance, there is no support provided. _s is provided “as-is”. It’s presumed those making use of it know what they’re doing and don’t need help. Now in the real world… 🙂

    I see child items under the one “Departments” main menu item. Are these the children you were having trouble with? If so, you’ve apparently solved the issue? Or are there supposed to be more children under the children I can see? If so, the respective HTML does not exist, so there’s an issue with your nav walker handling deeper levels.

    All _s does is provide a hierarchical ul/li structure with some minimal CSS to initially hide children until the parent is hovered over. But since you’ve layered Bootstrap over it and invoked a different nav walker, any issues related to this would be beyond the scope of _s support if there had been any to start with.

    It’s OK to ask general coding questions regarding nav walkers and Bootstrap here, but you’re less likely to get a meaningful answer the farther away you get from questions about core WP. We’ll then often try to direct you to better resources.

    Thread Starter clsimco

    (@clsimco)

    Happy New Year to all and many thanks to all of the moderators and others who give their time and expertise to help people learn and do!

    Thank you for your interest and response @bcworkz. I think you get where I’m coming from. I’ll take a moment to clarify my intentions here, as that, in and of itself, may also help someone else on this same journey of learning.

    I decided to set about learning how to create WordPress themes because I think WordPress is a fantastic and rich CMS for delivering content and exchange of information.

    This theme that I have been working on and have asked for help with, is really no more than a self assigned exercise, for me to learn and implement the core languages and technologies that underlie WordPress, and, that which is layered on top of the platform. As an aside, in reality, and ironically, the teacher that the site is about, DOES NOT WANT to have a website, I have since learned. As a result, I gain the benefits of the learning process.

    Your suggestion early on, when I was having issues with the comment form display really helped clarify for me the importance of keeping things simple as a starting point then building upon what works. Both for learning and actual development. _s helps on all of those counts. And yes, we all live in the real world ;^) and we all have needed help to learn at some point.

    With all that said, to your current points:

    “I see child items under the one “Departments” main menu item. Are these the children you were having trouble with? If so, you’ve apparently solved the issue? Or are there supposed to be more children under the children I can see? If so, the respective HTML does not exist, so there’s an issue with your nav walker handling deeper levels.”

    The fist level child is working, yes, but the issue is: getting at least a second child if not also a third child. Issue is not solved, or worked around. In my understanding of the class-Wp-Navwalker, that is what does the heavy lifting to work with WordPress to create a series of childern in a dropdown menu, in the process, eliminating the html for those page menu items. See the notes by the author on Github.

    You were right, _s does a fantastic job of providing the necessary framework, and I have found a couple of other themes on WordPress, that have layered bootstrap on top of _s, causing me to believe that what I want to do is is possible and could even be extended. However few bother with the extra work of the second and third child. That said, the Neve theme does seem to provide for that functionality, though not utilizing Bootstrap. So I can see that the ability of WordPress to allow for children and styling of them is latent.

    As a result of all of that I have decided that the possible best approach for me at this point is to again simplify by going back to a fresh installation of _s and focus entirely on the navbar, dropdowns and levels of children along with the Codex before layering anything else in to complicate things.

    I do have another unanswered question from the beginning of this topic that relates to WordPress core and php, however I will wait to pose that again until a bit later in hopes that I figure it out on my own.

    Best to all!

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

The topic ‘Nav bar dropdown issues’ is closed to new replies.