So I have two menus which has childs with the same name. How to get term by name but from specified parent?

1 Answer 1


Use get_terms and specify name and parent.

$name = 'Flowers';
$parent_id = 42;

$args = array(
    'name' => $name,
    'parent' => $parent_id
$terms = get_terms( 'category', $args );
  • Strange, but get_terms returns only 1 value, but in database I have 3... I use like this: get_terms('gp_hubs', ['name' => 'Vilniaus miestas/rajonas']) and get only one... Here is my db dropbox.com/s/rn8ru7ubcejdyhl/…
    – Kirix
    Jan 31, 2016 at 22:46
  • do all of them have posts assigned? you have to set hide_empty to false if you want terms that have no posts.
    – Milo
    Feb 1, 2016 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.