Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_custom_terms($taxonomy)
- {
- $args = array(
- 'parent' => 0,
- 'pad_counts' => true,
- 'hide_empty' => false
- );
- $terms = get_terms($taxonomy, $args);
- if (count($terms) != 0) {
- foreach ($terms as $term) {
- $term = sanitize_term($term, $taxonomy);
- $term_link = get_term_link($term, $taxonomy);
- if (is_wp_error($term_link)) {
- continue;
- }
- $array[] = $term->name;
- $term_children = get_term_children($term->term_id, $taxonomy);
- if (count($term_children) != 0) {
- foreach ($term_children as $term_id) {
- $term_child = get_term_by('id', $term_id, $taxonomy);
- $term_child = sanitize_term($term_child, $taxonomy);
- $term_child_link = get_term_link($term_child, $taxonomy);
- if (is_wp_error($term_child_link)) {
- continue;
- }
- $array[]['children'] = $term_children->name;
- }
- }
- }
- return $array;
- }
- }
Add Comment
Please, Sign In to add comment