Function Reference: geodir_helper_cat_list_output

Summary

Generates category list HTML.

Global Values

$geodir_post_category_str
(string) (required) The geodirectory post category.

Default: None

Package

GeoDirectory

Parameters

$terms
(array) (required) An array of term objects.

Default: None
$category_limit
(int) (required) Number of categories to display by default.

Default: None
$category_restrict
(bool) (required) If the cat limit should be hidden or not shown.

Default: None

Change Log

Since: 1.0.0

Filters

‘geodir_category_term_link’ [Line: 3035]

Source File

geodir_helper_cat_list_output() is located in geodirectory-functions/general_functions.php [Line: 3004]

Source Code

function geodir_helper_cat_list_output( $terms, $category_limit , $category_restrict=false) {
	global $geodir_post_category_str, $cat_count;
	$term_icons = geodir_get_term_icon();

	$geodir_post_category_str = array();


	foreach ( $terms as $cat ) {
		$post_type     = str_replace( "category", "", $cat->taxonomy );
		$term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : '';

		$cat_count ++;

		$geodir_post_category_str[] = array( 'posttype' => $post_type, 'termid' => $cat->term_id );

		$class_row  = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
		if($category_restrict && $cat_count > $category_limit ){
			continue;
		}
		$total_post = $cat->count;

		$term_link = get_term_link( $cat, $cat->taxonomy );
		/**
		 * Filer the category term link.
		 *
		 * @since 1.4.5
		 *
		 * @param string $term_link The term permalink.
		 * @param int $cat          ->term_id The term id.
		 * @param string $post_type WordPress post type.
		 */
		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );

		echo '
  • '; echo '' . esc_attr( $cat->name ) . ' icon '; echo $cat->name . ' (' . $total_post . ') '; echo '
  • '; } }