WordPress.org

Ready to get started?Download WordPress

Forums

Displaying category children--but NOT grandchildren (2 posts)

  1. JuryDuty
    Member
    Posted 1 year ago #

    I'm having trouble displaying category children WITHOUT grandchildren.

    Here's the current code I'm fiddling with:

    $portfoliocat = of_get_option('of_portfolio_cat', 'no entry' );
    $categories = get_categories('child_of='.$portfoliocat.'');

    If I add a parameter to the second line, such as...

    $categories = get_categories('child_of='.$portfoliocat.'&exclude=6');

    ...then I can get it to exclude one grandchild at a time. But I'd much rather just have it exclude them all so I don't have to mess with the code each time a new child or grandchild is created.

    Is this possible?

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    have a look at the 'parent' parameter:

    http://codex.wordpress.org/Function_Reference/get_categories

Topic Closed

This topic has been closed to new replies.

About this Topic