1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wordpress Category Help

Discussion in 'WordPress' started by Analyst, Oct 12, 2007.

  1. #1
    Hi,


    I want categories to be displayed in side bar like this:

    Main Category 1

    —-> Sub Category 1

    —-> Sub Category 2

    —-> Sub Category 3

    Main Category 2

    —-> Sub Category 1

    —-> Sub Category 2

    —-> Sub Category 3




    In sidebar.php the code is:

    <li><h2><?php _e('Categories'); ?></h2>
    		<ul>
    			<?php 
    wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    		</ul>
    	</li>
    PHP:

    Can anyone please tell me what to add in this code to have the desired category display?


    Thanks in anticipation!
     
    Analyst, Oct 12, 2007 IP
  2. Houdy

    Houdy Peon

    Messages:
    267
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Actually you can do this without any coding. Just add a new sub-category under the parent.

    Here is more: wordpressmax.com/wordpress-guide/wordpress-categories
     
    Houdy, Oct 13, 2007 IP
  3. sat123

    sat123 Banned

    Messages:
    1,600
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sat123, Oct 13, 2007 IP
  4. Analyst

    Analyst Well-Known Member

    Messages:
    623
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #4
    I'm stuck with the design in fact. Creating child category is not the issue instead displaying it. I've created child categories, but they display as parent.





    I want Categories to be displayed like this:

    Economics
    • Micro Economics
    • Macro Economics
    • Applied Economics
    Management
    • Organization
    • Planning
    • Decision Making




    But the categories are being displayed like this:

    • Applied Economics
    • Decision Making
    • Economics
    • Macro Economics
    • Management
    • Micro Economics
    • Organization
    • Planning



    @sat123

    just going through the link, let's see if i get something there. Thanks, BTW!
     
    Analyst, Oct 13, 2007 IP
  5. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #5
    Analyst did you find a solution to this? i currently have the same problem, did that plugin sort it for you and if so, does it work with 2.5.1?
     
    pipes, Jun 25, 2008 IP
  6. Analyst

    Analyst Well-Known Member

    Messages:
    623
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #6
    Yeah I found!
    It's like:
    <li><h2><?php _e('Categories'); ?></h2>
            <ul>
                <?php 
    wp_list_cats('sort_column=name&optioncount=1&hierarchical=1'); ?>
            </ul>
        </li>
    PHP:
    Just make the hierarchical '1' from '0' in sidebar.php of the theme you're using!
     
    Analyst, Jun 26, 2008 IP
    pipes likes this.
  7. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #7
    Excellent Analyst, thats sorted that part, do you know any way to only have the child categories show after clicking on the parent category?

    Thanks for the above code by the way. :)
     
    pipes, Jun 26, 2008 IP
  8. BANAGO

    BANAGO Active Member

    Messages:
    456
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Good Solution!
     
    BANAGO, Jun 26, 2008 IP
  9. Analyst

    Analyst Well-Known Member

    Messages:
    623
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #9
    All my pleasure pipes!

    The other thing is what I myself m' trying to find out. I'll update the thread as soon as I find something!


    Regards,
     
    Analyst, Jun 28, 2008 IP
  10. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #10
    Thanks very much Analyst, il also do the same and update here if i find anything sooner.
     
    pipes, Jun 28, 2008 IP
    Analyst likes this.