<?php
$args = array( 'type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false );
$categories = get_categories( $args );
var_dump($categories); // Returns an array of category objects matching the query parameters.
?>
type
(string) Type of category to retrieve
post - default
link
Note: type=link has been deprecated from WordPress 3.0 onwards. Use taxonomy=link_category instead.
child_of
(integer) Display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. There is no default for this parameter. If the parameter is used, the hide_empty parameter is set to false.
parent
(integer) Display only categories that are direct descendants (i.e. children only) of the category identified by its ID. This does NOT work like the 'child_of' parameter. There is no default for this parameter. [In 2.8.4]
orderby
(string) Sort categories alphabetically or by unique category ID. The default is sort by Category ID. Valid values:
id
name - default
slug
count
term_group
order
(string) Sort order for categories (either ascending or descending). The default is ascending. Valid values:
asc - default
desc
hide_empty
(boolean) Toggles the display of categories with no posts. The default is 1 for true or you can add '0' for false (show empty categories). Valid values:
1 - default
0
hierarchical
(boolean) When true, the results will include sub-categories that are empty, as long as those sub-categories have sub-categories that are not empty. The default is true. Valid values:
1 (true) - default
0 (false)
exclude
(string) Excludes one or more categories from the list generated by wp_list_categories. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See the example.
include
(string) Only include certain categories in the list generated by wp_list_categories. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See the example.
list - default.
none
number
(string) The number of categories to return
taxonomy
(string or array) Taxonomy to return. This parameter added at Version 3.0 Valid values:
category - default
taxonomy - or any registered taxonomy
pad_counts
(boolean) Calculates link or post counts by including items from child categories. Valid values:
1 (true)
0 (false) - default