Treehouse: Grow your CSS skills. Land your dream job.

Adding a submenu in the sidebar for a specific page

  • # December 8, 2010 at 10:21 pm

    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' ) ) {
    'menu' => 'Menu',
    'submenu' => 'Sidebar submenu'

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


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

    … 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,

    # December 9, 2010 at 10:12 pm

    I’m sorry to bump this, but I cannot figure out what to do. Can anyone help me?

    # December 10, 2010 at 8:07 am

    You could give the page a special page template. For example, ‘contact.php’

    < ?php
    if ( is_page_template('contact.php') ) {
    // Do whatever
    # December 10, 2010 at 9:05 am

    And is there a way that I set “Page Sidebar” with my custom menu in the widgets and it appears only when I’m on “some_site”? If so, what should I write in the code? I have been trying for some time but some strange things and errors appear?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.