Need help with Walker_Nav_Menu class
Need help with Walker_Nav_Menu class
Need help with Walker_Nav_Menu class
You’re right, it’s the object-oriented parts that are throwing you off. The nav menu call should be: wp_nav_menu(array( ‘theme_location’ => ‘menu-top’, ‘container’ => ‘ul’, ‘menu_class’ => ‘header_nav_ul’, ‘menu_id’ => ‘header_nav_id’, ‘depth’ => 0, ‘walker’ => new my_walker_nav_menu_start_el, )); no parentheses () after the name of the walker. The walker itself needs to extend Core’s Walker_Nav_Menu, … Read more
I think you can use this simple class: https://github.com/wp-bootstrap/wp-bootstrap-navwalker
I’m not sure if I missed something that’s more complex in your question, but sprintf should not be an issue with an img tag. If you want to specify the value as string you can use the %s handler. sprintf(‘<div>…<img src=”%s” />…</div>’, $thumbnail);
I can’t say for certain, but I’d wager that url_to_postid() is simply not a very fast function. You shouldn’t need to use it though, since the original post ID is available from $item: if ( ‘post’ === $item->object ) { $post_id = $item->object_id; $thumbnail = get_the_post_thumbnail_url( $post_id ); }
Why is my navigation in my onepage not working?
Help with WordPress Custom Nav Walker
Here is your code <script> $(document).ready(function(){ $( “.product-menu .sub-menu-level-1” ).after( “<div>SHOW ONCE</div>” ); }); </script> This will automatically add the div if the parent has a class name of product-menu. Let me know if I miss something. and if this solved your issue, give a thumb
Without testing & debugging your example I’m not 100% certain what’s going wrong. I noticed your walker doesn’t have a end_lvl method which would be my first guess as to why dropdowns past the first level won’t work. Here’s a copy of a Nav Walker that I’m certain handles nested nav menus well. You’ll want … Read more
Modifying the wrapper for the wp_nav_menu() is customizable with the items_wrap parameter. https://developer.wordpress.org/reference/functions/wp_nav_menu/ The documentation states that the default wrapper is a <ul> element with an ID an CLASS attribute. This can be modified as you wish by modifying the markup passed to the sprintf() function used by wp_nav_menu(). The value for items_wrap is the … Read more