• Hi guys,

    I found some code that tells WordPress to list all child categories belonging to a post. It works well but can anyone help to amend it so each is a link separated by a comma?

    Thanks

    <?php $post_child_cat = array();
    foreach((get_the_category()) as $cats) {
        $args = array( 'child_of' => $cats->cat_ID );
    	$categories = get_categories( $args );
    	if( $categories ) foreach( $categories as $category ) {
    	echo $category->cat_name; }
    } ?>
  • The topic ‘How to list child categories of a post as links?’ is closed to new replies.