• bloser

    (@bloser)


    Hi,

    I am running a website with a theme I purchased from themeforest.com
    I have a primary menu, with standard drop-down functionality.

    What I want to achieve, is to create a secondary menu, which will not be shown on the homepage, and which would be different for each page,category archive, etc. For example, if i click the parent category link (Music), i would like a new page to open, showing the contents of that category, and as well as a second menu below the first one, showing the child categories.

    An example is:
    https://www.complex.com/

    After clicking on ‘Music’ >
    https://www.complex.com/music/

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    (@esmi)

    As this is a commercial theme, you need to seek support from the theme’s vendors.

    Thread Starter bloser

    (@bloser)

    Ok, so now I’ve set my theme to Twenty Eleven 1.3

    Can you please give me any suggestions on how to make this secondary menu for Twenty Eleven 1.3?

    esmi

    (@esmi)

    You’ll need to start by creating a child theme.

    Thread Starter bloser

    (@bloser)

    I don’t see the reason for creating a child theme. I want to directly modify the php code and css for my website.

    I’m not a beginner in php and wordpress, so any piece of code to put me on the right path would be helpful.

    esmi

    (@esmi)

    You should never edit the Twenty Eleven theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. Create a child theme for your changes.

    Thread Starter bloser

    (@bloser)

    Ok, I’ve created the child theme..

    esmi

    (@esmi)

    You will need to add a copy of header.php to your child theme. Working on this template file, try using wp_list_categories with the child_of parameter to list specific sub-categories. I’d suggest adding the new code just before </header><!-- #branding -->. You should be able to grab the id of the current category using get_query_var('cat'), so overall the code would look something like:

    <?php if( is_category() ) :
    $this_cat_id = get_query_var('cat');?>
    <ul class="sub-menu">
    <?php wp_list_categories('child_of=' . $this_cat_id); ?>
    </ul>
    <?php endif;?>

    The rest is down to CSS.

    Thread Starter bloser

    (@bloser)

    Thank you for your help. Can you please give me a hint on creating the css for this menu to be dynamic (i.e. for the category archive to expand the div in which this menu is located)

    esmi

    (@esmi)

    Sorry? I don’t follow.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Secondary menu with child categories links’ is closed to new replies.