php - Show only child categories of current category page -


i having hard time getting children current category page. instance on on page category 4. seems pulling it's siblings right instead of the children. not want siblings in there, children. here code:

 <?php  $this_category = get_the_category();  $child_categories=get_categories( array( 'parent' => $this_category->cat_id,));      foreach($child_categories $category) {           $category_url = get_category_link( $category->term_id );          $category_name = $category->cat_name;          $category_description = $category->description;  ?>  <div class="col3">      <img src="<?php echo z_taxonomy_image_url($category->term_id, array(365, 165)); ?>">      <h3><a href="<?php echo $category_url?>"><?php echo $category_name?></a></h3>      <p><?php echo $category_description?></p>      <a class="view-more" href="<?php echo $category_url?>">view more</a>  </div>  <?php  }?> 

any appreciated.

i figured out after realizing using wrong wordpress _get functions.

                $this_category = get_category( $cat );                 $child_categories=get_categories( array( 'child_of' => $this_category->cat_id,));                 foreach($child_categories $category) {                          $category_url = get_category_link( $category->term_id );                         $category_name = $category->cat_name;                         $category_description = $category->description;                     ?>                 <div class="col3">                     <img src="<?php echo z_taxonomy_image_url($category->term_id, array(365, 165)); ?>">                   <h3><a href="<?php echo $category_url?>"><?php echo $category_name?></a></h3>                   <p><?php echo $category_description?></p>                   <a class="view-more" href="<?php echo $category_url?>">view more</a>                 </div>                     <?php                 }?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -