Link to Homepage in Menu

You can take the following steps Go to You Dashboard Click Appearance > Menus Under Pages, Click View All There will be a ‘Home’ option Check that Home Option Click ‘Add to Menu’ The new Menu item will appear in the right block Drag the home menu to the top Save the menu

Making sub-menus exclusive [closed]

I’m making some assumptions here, like you are the one writing the code for the theme, or at least have the ability to modify the JavaScript in some way. You can accomplish this using jQuery using code along these lines: $(document).ready(function () { $(‘.parent ul’).slideUp(); $(‘.parent > li > a’).on(‘click’, function (e) { e.preventDefault(); var … Read more

Prepend to start of WordPress nav loop

Instead of using a Walker in this instance you can use the items_wrap parameter of wp_nav_menu. $args = array( ‘container’ => ‘nav’, ‘container_class’ => ‘c-nav c-nav–vertical c-nav–collapsible’, ‘menu_class’ => ‘c-nav__collapser’, ‘theme_location’ => ‘secondary’, ‘items_wrap’ => menu_wrapper() ); wp_nav_menu($args); In the called function you can use the arguments for %1$s (id), %2$s (class), and %3$s (all … Read more

How to add programmatically all pages and children to backend menu

The helpers you’ll need are wp_create_nav_menu() and wp_update_nav_menu_item(). This will allow you to create a menu and then, using a query posts loop, programmatically add every page in your site dynamically. You can use the get_pages() helper to retrieve all pages from the DB. <?php // These are default args and don’t need to be … Read more

How to replace the page url for the page slug in a menu link?

To be able to change the Link, you can hook into the nav_menu_link_attributes filter. if ( ! function_exists( ‘wpse_209457_nav_menu_link_attributes’ ) ) { function wpse_209457_nav_menu_link_attributes( $atts, $item, $args ) { if ( ‘primary-menu’ == $args->theme_location ) { // Get the target posts slug $object_data = get_post( $item->object_id ); $atts[‘href’] = ‘#’.$object_data->post_name; return $atts; } } } … Read more