Subscibe our Newsletter for FREE and stay up to date with our daily lesson*

Custom Options For WordPress Category List

Usually, WordPress Themes have category list in their PHP code. Actually you can put your own category list on your sidebar widget or in anywhere in your theme using PHP implementation.

To put wordpress category list, you have to put PHP snippets like

<?php wp_list_categories($args);?>

You can left the $args blank for default settings but if you want a modification, the list of arguments is below:

  1. ’show_option_all’ (string) – Text to display for showing all categories.
  2. ‘orderby’ (string) default is ‘ID’ – What column to use for ordering the categories.
  3. ‘order’ (string) default is ‘ASC’ – What direction to order categories.
  4. ’show_last_update’ (bool|int) default is 0
  5. ’show_count’ (bool|int) default is 0 – Whether to show how many posts are in the category.
  6. ‘hide_empty’ (bool|int) default is 1 – Whether to hide categories that don’t have any posts attached to them.
  7. use_desc_for_title’ (bool|int) default is 1 – Whether to use the description instead of the category title.
  8. feed’
  9. ‘feed_type’
  10. ‘feed_image’
  11. ‘child_of’ (int) default is 0
  12. ‘exclude’ (string)
  13. ‘exclude_tree’ (string)
  14. ‘echo’ (bool|int) default is 1 – Whether to display or retrieve content.
  15. ‘current_category’ (int)
  16. ‘hierarchical’ (bool)
  17. ‘title_li’ (string)
  18. ‘depth’ (int) – The max depth.

For example you may see cases below:

  1. Show Only Parent Categories

    <?php wp_list_categories("depth=1");?>

  2. Show Categories Order by Name and Only Parent Categories

    <?php wp_list_categories("depth=1&orderby=name");?>

  3. Show Categories Order by Quantity

    <?php wp_list_categories("orderby=count");?>

  4. Show Categories Only The Parent and Second Branch

    <?php wp_list_categories("depth=2");?>

  5. Show Category List Including Categories which are empty

    <?php wp_list_categories("hide_empty=1");?>

Let's talk it out!

10 Responses to “Custom Options For WordPress Category List”

  • Field Turf

    Great information, Thank you so much… keep up the great work.


  • forex robot

    What a great resource!


  • artificial turf

    Great post… keep it coming! I only wish there were more websites like this.


  • Orange County Turf

    I love the post… Check out my synthetic turf siteOrange County Turf… keep up the good work.


  • 71.226.239.53:8085

    This article was a very good read! I could not have explained things better myself.


  • Belinskiy

    Very useful information! Thank you very much!


  • MrCairney

    I wonder if it’s possible to display child categories only? I’ve been hunting and can’t seem to find the answer.


    • Julian

      to display child category, you have to know the parent category id, it can be took from Category tab on your DashBoard

      after that, you can insert the property “child_of” within the PHP function

      for example if your category is “Blog” and the category id is 5, then the list of the child “Blog” category would be

      < ?php wp_list_categories("child_of=5");?>


  • Dianna

    Helpful story, saved the site in interest to read more information!


What is in your mind ?

Subscribe Me

Learn more the basic tips about WordPress and PHP coding. You can subscribe to our Newsletter to stay in touch with every new stories FREE

Sponsors

WooThemes - Where there's a Woo, there's a way!

Our FaceBook (new)


Discussion Topics

Who am I ?

My name is Julian Widya Perdana. I study at University of Gadjah Mada, Yogyakarta. I am a young developer addicted in JavaScript, Plugins, Themes, AJAX, and PHP developement. If you need anything, then submit it on Contact Us. If you feel satisfy with my work, please support me to keep it developed

Our Community

Discussion

Google Adsense Friendly

Thanks for the tips. We'll try it now.

julian

i will fix it on newer version thanks for informing the bug :-D

Timothy Rusher

A good background check service is almost impossible to find.
Close