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:
- ’show_option_all’ (string) – Text to display for showing all categories.
- ‘orderby’ (string) default is ‘ID’ – What column to use for ordering the categories.
- ‘order’ (string) default is ‘ASC’ – What direction to order categories.
- ’show_last_update’ (bool|int) default is 0
- ’show_count’ (bool|int) default is 0 – Whether to show how many posts are in the category.
- ‘hide_empty’ (bool|int) default is 1 – Whether to hide categories that don’t have any posts attached to them.
- use_desc_for_title’ (bool|int) default is 1 – Whether to use the description instead of the category title.
- feed’
- ‘feed_type’
- ‘feed_image’
- ‘child_of’ (int) default is 0
- ‘exclude’ (string)
- ‘exclude_tree’ (string)
- ‘echo’ (bool|int) default is 1 – Whether to display or retrieve content.
- ‘current_category’ (int)
- ‘hierarchical’ (bool)
- ‘title_li’ (string)
- ‘depth’ (int) – The max depth.
For example you may see cases below:
-
Show Only Parent Categories
<?php wp_list_categories("depth=1");?> -
Show Categories Order by Name and Only Parent Categories
<?php wp_list_categories("depth=1&orderby=name");?> -
Show Categories Order by Quantity
<?php wp_list_categories("orderby=count");?> -
Show Categories Only The Parent and Second Branch
<?php wp_list_categories("depth=2");?> -
Show Category List Including Categories which are empty
<?php wp_list_categories("hide_empty=1");?>






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!