I am trying to populate an array with a list of categories in a custom taxonomy I created.

The taxonomy, called clips, has a slug called clipcat. I only want the array to populate with children of a clip with the same slug as the page slug the list is on.

Here's my code so far:

        global $post;
        $slug = get_post( $post )->post_name;
        $taxes = array('clipcat');
        $args = array(
            'parent' => $slug,
        $categories = get_terms( $taxes, $args );

To my knowledge, the code is as it should be, but when I print the array (the last line in the code), the array is empty even though I know the clip category that is successfully assigned to $slug has three sub categories (so I must be coding something wrong).

Any suggestions to what I'm doing wrong?

  • The parent arg accepts an integer(ID), you are passing the slug. – Duane Jul 17 '14 at 16:35
  • Also, make sure you want 'parent' and not 'child_of'. – mrwweb Jul 17 '14 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.