• Hey everybody,

    I’d like to get a category cloud for all direct sub-categories (only the next level) of the category (archive) that I’m viewing at the moment. Is this possible using the wp_tag_cloud function?

    Thanks in advance,
    René

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter renet

    (@renet)

    Nobody got an idea? Any simple alternatives are welcome. ??

    This will work:

    <?php
    $childcategories = get_categories('child_of=' . $cat . '&hide_empty=1');
    foreach ($childcategories as $childcategory) {
    if (in_category($childcategory)) {
    $childs  = array($childcategory->cat_ID);
    foreach($childs as $idofchild){$string .= $idofchild.',';} } }
    $args = array( 'taxonomy' => 'category','include' => $string);
    wp_tag_cloud( $args);
     ?>

    And here a Version for all descendant categories:

    <?php
    $childcategories = get_categories('child_of=' . $cat . '&hide_empty=1');
    foreach ($childcategories as $childcategory) {
    $childs  = array($childcategory->cat_ID);
    foreach($childs as $idofchild){$string .= $idofchild.',';} }
    $args = array( 'taxonomy' => 'category','include' => $string);
    wp_tag_cloud( $args);
     ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Category cloud for direct sub-categories of a certain category’ is closed to new replies.