WordPress.org

Ready to get started?Download WordPress

Forums

how to create multiply categories in the main menu Imbalance theme (4 posts)

  1. kozzo
    Member
    Posted 1 year ago #

    Hello!
    My website is http://mart-studio.com/
    I use the Imbalance theme http://wpshower.com/demo/?theme=imbalance
    I am the beginner wp user.
    The only thing I need to change is to add the second "category" with subcategories in the main menu.
    I was trying to do it by adding the category in the "header.php" like this:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser. ]

    <div id="cats">
    
    <ul>
    <li><a href="#" rel="toggle[categories]" title="">interior design</a></li>
    <li><a href="#" rel="toggle[categories2]" title="">architecture</a></li>
                    	<?php
    				    if ( function_exists( 'wp_nav_menu' ) ) {
    				    	wp_nav_menu( array( 'theme_location' => 'custom-menu' , 'container' => '' , 'fallback_cb'=> 'custom_menu' , 'depth' => 1 ) ); }
    				    else
    					    { custom_menu(); }
    					?>
                    </ul>
                </div>
            </div>
            <div id="categories">
                <ul class="mcol2">
    				  <?php
                        $data = wp_list_categories('show_count=1&echo=0&title_li=&depth=1&hide_empty=0&orderby=name&include=8,1,11');
                        $data = preg_replace('/\<\/a\> \((.*)\)/',' <span>$1</span>',$data);
                        echo $data;
                      ?>
    
            </div>
     <div id="categories2">
                <ul class="mcol2">
    				  <?php
                        $data = wp_list_categories('show_count=1&echo=0&title_li=&depth=1&hide_empty=0&orderby=name&include=18,17');
                        $data = preg_replace('/\<\/a\> \((.*)\)/',' <span>$1</span>',$data);
                        echo $data;
                      ?>
    
            </div>

    But unfortunately the subcategories of the second category "architecture" appear everywhere, but not below "architecture".
    How can I solve this?
    Thanks for any help in advance

  2. namielus
    Member
    Posted 1 year ago #

    Hi kozzo,

    I found your website, and am trying to do something similar (a second list of categories that expand and collapse), but I can't seem to make it work.

    May I ask how you managed to do that?

    In advance - thank you.

    Sul

  3. kozzo
    Member
    Posted 1 year ago #

    oops. once again

    First, open your collapse.js, you'll have to use a texteditor + ftp for this, as you cant edit it from the wordpress CMS.
    Duplicate the line which contains "categories".
    Change "categories" to something else of your choice, but use it consistently from this point. I used the keyword "kontor" as that is the links name in the menu.

    Then go through your style.css file and search for "categories", add your keyword here, in the same way that "categories" is written.
    #categories ul li, #archives ul li {
    would become
    #categories ul li, #archives ul li, #kontor ul li {
    Now edit your header.php
    I added a line for "kontor" like this:

    <li><a href="#" rel="toggle[categories]" title="">Kategorier</a></li>
    <li><a href="#" rel="toggle[kontor]" title="">Kontor</a></li>
    <li><a href="#" rel="toggle[archives]" title="">Arkiv</a></li>
     And then a whole new div for the actual menu:
     <div id="kontor">
     <ul class="mcol2">
     <?php
     $data = wp_list_categories('echo=0&title_li=&depth=1&hide_empty =0&orderby=ID');
     $data = preg_replace('/\<\/a\> \((.*)\)/',' <span>$2</span>',$data);
     echo $data;
     ?>
    
     </div>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  4. kozzo
    Member
    Posted 1 year ago #

    First, open your collapse.js, you'll have to use a texteditor + ftp for this, as you cant edit it from the wordpress CMS.
    Duplicate the line which contains "categories".
    Change "categories" to something else of your choice, but use it consistently from this point. I used the keyword "kontor" as that is the links name in the menu.

    Then go through your style.css file and search for "categories", add your keyword here, in the same way that "categories" is written.

    #categories ul li, #archives ul li {
     would become
     #categories ul li, #archives ul li, #kontor ul li {
     Now edit your header.php
     I added a line for "kontor" like this:
     <li><a href="#" rel="toggle[categories]" title="">Kategorier</a></li>
     <li><a href="#" rel="toggle[kontor]" title="">Kontor</a></li>
     <li><a href="#" rel="toggle[archives]" title="">Arkiv</a></li>
     And then a whole new div for the actual menu:
     <div id="kontor">
     <ul class="mcol2">
     <?php
     $data = wp_list_categories('echo=0&title_li=&depth=1&hide_empty =0&orderby=ID');
     $data = preg_replace('/\<\/a\> \((.*)\)/',' <span>$2</span></a>',$data);
     echo $data;
     ?>
     </ul>
     </div>

Topic Closed

This topic has been closed to new replies.

About this Topic