Skip to content

Instantly share code, notes, and snippets.

@icetee
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icetee/8b9a7aa3edc44a9daca9 to your computer and use it in GitHub Desktop.
Save icetee/8b9a7aa3edc44a9daca9 to your computer and use it in GitHub Desktop.
get_custom_categories() in WordPress
function get_custom_categories($slug) {
$args = array(
'hide_empty' => 1,
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'taxonomy' => $slug,
'title_li' => '',
'style' => 'none',
'echo' => 0
);
$cat = wp_list_categories($args);
preg_match_all("/<a.*?>(.*?)<\/a>/", $cat, $matches);
return $matches;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment