ap_category_details()

Description #

Get category details.

Source #

File: includes/taxo.php

function ap_category_details() {
	$var      = get_query_var( 'question_category' );
	$category = get_term_by( 'slug', $var, 'question_category' );

	echo '<div class="clearfix">';
	echo '<h3><a href="' . esc_url( get_category_link( $category ) ) . '">' . esc_html( $category->name ) . '</a></h3>';
	echo '<div class="ap-taxo-meta">';
	echo '<span class="count">' . (int) $category->count . ' ' . esc_attr__( 'Questions', 'anspress-question-answer' ) . '</span>';
	echo '<a class="aicon-rss feed-link" href="' . esc_url( get_term_feed_link( $category->term_id, 'question_category' ) ) . '" title="Subscribe to ' . esc_attr( $category->name ) . '" rel="nofollow"></a>';
	echo '</div>';
	echo '</div>';

	echo '<p class="desc clearfix">' . wp_kses_post( $category->description ) . '</p>';

	$child = get_terms(
		array(
			'taxonomy'     => 'question_category',
			'parent'       => $category->term_id,
			'hierarchical' => false,
			'hide_empty'   => false,
		)
	);

	if ( $child ) :
		echo '<ul class="ap-child-list clearfix">';
		foreach ( $child as $key => $c ) :
			echo '<li><a class="taxo-title" href="' . esc_url( get_category_link( $c ) ) . '">' . esc_html( $c->name ) . '<span>' . (int) $c->count . '</span></a>';
			echo '</li>';
		endforeach;
		echo '</ul>';
	endif;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment