• Resolved Dennis

    (@enggsoldennis)


    I’m trying to get the child categories of a category named “Products” with ID 4.

    $args = array(
    ‘type’ => ‘post’,
    ‘parent’ => 4,
    ‘orderby’ => ‘name’,
    ‘order’ => ‘ASC’,
    ‘hide_empty’ => 1,
    ‘hierarchical’ => 1,
    ‘exclude’ => ”,
    ‘include’ => ”,
    ‘number’ => ”,
    ‘taxonomy’ => ‘category’,
    ‘pad_counts’ => false );

    $prod_cats = get_categories($args);

    Referring to the Codex, I’ve tried putting 4 in child of and parent.
    And it returns nothing.

    I also tried get_categories() without $args, and it doesn’t include my child categories.

    Any idea guys?

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Dennis

    (@enggsoldennis)

    Solved my own problem.

    WordPress doesn’t recognize unused categories(categories with no post under it).

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble getting child categories.’ is closed to new replies.