post - wordpress is_category of all subcategories of parent category -
i want show certien code inside posts (single.php) assosiated sub cats of 1 father cat. want code work post under sub cats (that under main cat)
i have tryed this:
<?php function get_child_cats( $catname ) { $parentcat = get_cat_id(8); $subcat = get_categories( array('child_of' => $parentcat ) ); $cat_array = array(); array_push($cat_array, $parentcat); // add parent cat array foreach ($subcat $sc) { array_push($cat_array, $sc->cat_id); } return $cat_array; }?>
and this:
<?php if (in_category(8) && !is_feed()) { ?>
this how done:
<?php $mycats = array(8); foreach (get_the_category() $childcat) { foreach ($mycats $mycat) { if (cat_is_ancestor_of($mycat, $childcat)) { ?> <ul> <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=8'); ?></ul> <?php break 2; } } } ?>
Comments
Post a Comment