Forums

Adding a submenu in the sidebar for a specific page (1 post)

  1. Krallebabz
    Member
    Posted 1 year ago #

    Hello there! :-)

    I'm working on a site, and I'm new to WordPress. I've spent hours on Google trying to find a solution to my problem, but I honestly don't know how to fix this. I'm looking for a way to add a submenu in the sidebar to a specific page. I could imagine, I'd have to use the built-in-Wordpress custom navigation menu and perhaps set up two types of menus, which I've done here in the functions.php-file:

    if ( function_exists( 'register_nav_menus' ) ) {
    	register_nav_menus(
    		array(
    		  'menu' => 'Menu',
    		  'submenu' => 'Sidebar submenu'
    		)
    	);
    }

    In the header.php I've written the following:

    <ul id="topmenu">
    				<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_id' => 'topmenu', 'theme_location' => 'primary', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    			</ul>

    ... and it works perfectly with the CSS, except for the fact that the submenu-item is still stuck at the #topmenu. I'm sure I'd have to put something in the sidebar.php to let the links to the "children" pages of the parent page show there, but I don't know what to put in sidebar.php. This of course means that I've set the submenu-pages to be a child of the parent page in the Dashboard's page-overview-options. I also need the sidebar-submenus to contain some sort of id or class, since I'm styling them via CSS.

    I'd love to get some help on this. Thanks in advance,
    Kralle

Topic Closed

This topic has been closed to new replies.

About this Topic