Viewing 14 replies - 1 through 14 (of 14 total)
  • single.php is going to show just one post, so `the_category(‘> ‘,’multiple’) will show the category parent/children.

    But maybe this:

    <?php
    $category = get_the_category();
    if ($category) {
    wp_list_categories(‘child_of=’.$category[0]);
    }
    ?>
    `

    Thread Starter Marcomail

    (@marcomail)

    i’m not interested to show all the child categories, i’d show only the child of the current post 🙁

    Actually now that I think about this I’m confused about what you are trying to achieve…

    Regardless, here’s a correction:

    wp_list_categories('child_of='.$category->cat_ID);
    Thread Starter Marcomail

    (@marcomail)

    i would show only the current post child categories.

    for example i have this categories:

    -> fruits [X]
    –> apple [X]
    –> strawberry
    –> banana

    the post is under “fruits –> apple”

    i would show in single.php only the child category name “apple”

    sorry but my english is not perfect so it’s a little difficult explain better for me 🙂

    But you should be able to use ‘the_category’ for that.

    When you write a post you should only be checking apple for the category.

    Thread Starter Marcomail

    (@marcomail)

    ok, but what’s the difference if i select or not “fruits” ? it’s not better check “fruits” every time?

    You should not check both the parent and the child. Just the child.

    Thread Starter Marcomail

    (@marcomail)

    but why ?

    Beacuse the child is automatically under the parent.

    If you chose the parent as well, now it’s also part of that category, and it will display all the little “brothers and sisters” of the child…

    Thread Starter Marcomail

    (@marcomail)

    is it possible show the rss link near the category with the_category ?

    Thread Starter Marcomail

    (@marcomail)

    ok, thanks…the problem is now don’t work in_category(2) in single.php :((

    Thread Starter Marcomail

    (@marcomail)

    ok, i’ve solved with this code

    $in_subcategory = false;
    foreach( (array) get_term_children( 86, 'category' ) as $child_category ) {
    if(in_category($child_category))$in_subcategory = true;
    }
    if ($in_subcategory):

    but why if i use this code in header.php if i use if ($in_subcategory): in single.php it doesn’t work ?

    Thread Starter Marcomail

    (@marcomail)

    someone ?

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Select name of category’ is closed to new replies.