WordPress.org

Ready to get started?Download WordPress

Forums

Custom taxonomy children (get_term_children) - BUG? (3 posts)

  1. miradev
    Member
    Posted 4 years ago #

    I can't get WP to give me child terms on a custom taxonomy, here's an example:

    register_taxonomy( 'where-you-live', 'user', array('hierarchical' => true,  'show_ui' => true, 'query_var' => true, 'label' => __('Where they live')) );
    
    $country = 'USA';
    $state   = 'New York';
    
    $tax_country = wp_insert_term($country,  'where-you-live');
    $country_term_id = $tax_country['term_id'];
    wp_insert_term($state, 'where-you-live', array('parent'=>$country_term_id));
    
    $state_terms = get_child_terms($country_term_id, 'where-you-live');
    error_log(print_r($state_terms,1));

    This gives me an empty array. Have I done this wrong?

  2. miradev
    Member
    Posted 4 years ago #

    No comments on this in 5 days. Has anyone successfully done this? Am I the only one trying to do it?

    How do I go about figuring out if it is a bug, and if so where do I report it?

  3. Ameisenman
    Member
    Posted 3 years ago #

    Change the get_child_terms to get_term_children and you are fine!

Topic Closed

This topic has been closed to new replies.

About this Topic