Forums

is_category_child_of (4 posts)

  1. crizon
    Member
    Posted 3 months ago #

    Hello,

    I'm trying to figure how I can let wordpress check if the current category is the child of a certain category.

    I have found this function:
    http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of

    This is nearly what I'm looking for, but I don't need 2 specific categories, but a specific parent category and the _currently_ displayed category.

    Has anybody ideas how to solve this?

    Thanks

  2. dor
    Member
    Posted 3 months ago #

    in_category() ?..

  3. crizon
    Member
    Posted 3 months ago #

    I thought that one is used to check if a post is in a certain category. I'd like to check if the currently displayed category is the child of a certain parent-category.

    The relevant code for my sidebar:

    <?php if (is_category('Design') {
    wp_list_cats('child_of=7&optioncount=0');
    } elseif (is_category('Media')) {
    wp_list_cats('child_of=8&optioncount=0');
    } elseif (is_category('Work')) {
    wp_list_cats('child_of=9&optioncount=0');
    } else {
    wp_list_cats('sort_column=name&optioncount=0&hierarchical=0&list=1'); } ?>

  4. crizon
    Member
    Posted 3 months ago #

    Has nobody an idea how to solve this problem?
    It really is a roadblock for me right now.

Reply

You must log in to post.

About this Topic