WordPress.org

Ready to get started?Download WordPress

Forums

Children of Current Category (3 posts)

  1. shaneholden
    Member
    Posted 5 years ago #

    I'm wanting to edit the category.php page to show the children of the current category.

    For instance, Domestic > Fruit > Apple, Orange, Pineapple

    When you are on the Fruit category page, I'd like for it to just list the subcategories of it.

    Here's the code from the codex, but from what I see you have to specify what category to show the children from.

    <ul>
    <?php wp_list_categories('orderby=id&show_count=1
    &use_desc_for_title=0&child_of=8'); ?>
    </ul>

    Is this possible?

  2. shaneholden
    Member
    Posted 5 years ago #

    Ok, the only way that I've been able to see to do this is to create a custome category-x.php for each category, and manually add in an image and link to the children that exist for x category. The only problem is that there are going to be a few hundred.

    Is that reasonable to do? The headache would come if there should ever be an addition that would effect every one of these categories.

  3. shaneholden
    Member
    Posted 5 years ago #

    Maybe one last possible solution that might work.

    How would I do something like, if category has children and has no posts, list the children, but if category has no children and has posts, show posts?

    Basically, the posts will only be made on the deepest sub categories that are available.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.