Skip to content

Instantly share code, notes, and snippets.

@UVLabs
Created April 7, 2016 21:45
Show Gist options
  • Save UVLabs/89c4247882e8a7634edf76612e03f642 to your computer and use it in GitHub Desktop.
Save UVLabs/89c4247882e8a7634edf76612e03f642 to your computer and use it in GitHub Desktop.
Get all categories on site, whether custom post type or w/e. change parent array to '', to get all categories, including children.
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => 0,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'course',
'pad_counts' => false );
$categories = get_categories( $args );
foreach ($categories as $cat2) {
echo $cat2->name.'</br>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment