• Resolved peterjharrison

    (@peterjharrison)


    Hi,

    I’m having an issue with the get_terms() function.

    If I use:

    <?php
    $terms = get_terms( 'location' );
    print_r($terms);
    ?>

    I get an array back:

    Array ( [0] => stdClass Object ( [term_id] => 8 [name] => Aberdare [slug] => aberdare [term_group] => 0 [term_taxonomy_id] => 8 [taxonomy] => location [description] => [parent] => 7 [count] => 1 ) [1] => stdClass Object ( [term_id] => 10 [name] => Aberdeen [slug] => aberdeen [term_group] => 0 [term_taxonomy_id] => 10 [taxonomy] => location [description] => [parent] => 9 [count] => 14 ) [2] => stdClass Object ( [term_id] => 17 [name] => Aberdeenshire [slug] => aberdeenshire [term_group] => 0 [term_taxonomy_id] => 17 [taxonomy] => location [description] => [parent] => 9 [count] => 41 ) [3] => stdClass Object ( [term_id] => 1203 [name] => Aberdour [slug] => aberdour [term_group] => 0 [term_taxonomy_id] => 1203 [taxonomy] => location [description] => [parent] => 446 [count] => 1 );

    But if I try and get the terms with the parent of of any number of child_of the array comes back empty.

    <?php
    $terms = get_terms( 'location', array('parent' => 9) );
    print_r($terms);
    ?>

    I get this:

    Array ( )

    Does any one know what i’m doing wrong?

    Thanks
    Pete

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_terms returning empty array’ is closed to new replies.