I want to display only parent categories in wordpress

Discussion in 'HTML & Website Design' started by beebar, Jan 19, 2013.

  1. #1
    I would be happy if somebody in the house can put me through on how to edit WordPress file or whatever to hide subcategories at my sidebar and show only parent categories so as to minimize space at the sidebar. Thank in advance
     
    beebar, Jan 19, 2013 IP
  2. Hefaistos

    Hefaistos Active Member

    Messages:
    194
    Likes Received:
    14
    Best Answers:
    9
    Trophy Points:
    63
    Digital Goods:
    1
    #2
    It's easy. Just go to your admin panel -> Appearance -> Widgets ,
    find categories widget , click on the right arrow and will display three options checkboxes : Display as dropdown , Show post counts and Show hierarchy .

    Uncheck "Show hierarchy" and click Save button.
     
    Hefaistos, Jan 19, 2013 IP
  3. hor3tio

    hor3tio Well-Known Member

    Messages:
    253
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Or if you don't have widgets and you want to edit it in sidebar.php file you can add this:

    <ul>
    <?php wp_list_categories('hierarchical=0'); ?> 
    </ul>
    Code (markup):
     
    hor3tio, Jan 20, 2013 IP
  4. beebar

    beebar Greenhorn

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Thank U so much. I used option 1 above by Hefaistos, the subcategories links were still showing under parent categories. I want to get rid of the subcategories links from showing. I tried to utilized option 2 but to no avail, and i guess maybe i don't know on what line in the sidebar php to paste the code. Any additional advise?
     
    beebar, Jan 20, 2013 IP
  5. TwitTwit

    TwitTwit Active Member

    Messages:
    117
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    55
    Digital Goods:
    1
    #5
    How do you currently displaying your categories? Widget?

    If you don't mind using hardcode you can use this on your sidebar.php file:
    <ul>
     <?php wp_list_categories('depth=1'); ?>
     </ul>
    Code (markup):
     
    TwitTwit, Jan 20, 2013 IP