Forums

[resolved] Get IDs of children of category X (2 posts)

  1. renato_s
    Member
    Posted 3 years ago #

    Hi!
    I thought it was an easy task but am not managing to solve it. All I want is to make a loop to display 5 posts for every child-category of a specific category. To do this, I guess I have to obtain the IDs of those categories but I can't find out how to do this.

    Here's what I ant to do:
    1. Obtain all IDs for children of category X;
    2. For each child-category, create a Loop with get_posts;
    3. Display information about the posts for each child category;

    The thing is that these child-categories will be continuously updated, so I had to search for them automatically...

  2. renato_s
    Member
    Posted 3 years ago #

    Sorry...
    I found it just after I posted the question.

    One has to use get_categories('child_of=X');

    It will return an array that can be manipulated through foreach.

Topic Closed

This topic has been closed to new replies.

About this Topic