Categories::categories_page()

Description #

Categories page layout

Source #

File: addons/categories/categories.php

	public function categories_page() {
		global $question_categories, $ap_max_num_pages, $ap_per_page;

		$paged            = max( 1, get_query_var( 'paged' ) );
		$per_page         = ap_opt( 'categories_per_page' );
		$total_terms      = wp_count_terms(
			array(
				'taxonomy'   => 'question_category',
				'hide_empty' => false,
				'parent'     => 0,
			)
		);
		$offset           = $per_page * ( $paged - 1 );
		$ap_max_num_pages = ceil( $total_terms / $per_page );

		$order = ap_opt( 'categories_page_order' ) === 'ASC' ? 'ASC' : 'DESC';

		$cat_args = array(
			'parent'     => 0,
			'number'     => $per_page,
			'offset'     => $offset,
			'hide_empty' => false,
			'orderby'    => ap_opt( 'categories_page_orderby' ),
			'order'      => $order,
		);

		/**
		 * Filter applied before getting categories.
		 *
		 * @param array $cat_args `get_terms` arguments.
		 * @since 1.0
		 */
		$cat_args             = apply_filters( 'ap_categories_shortcode_args', $cat_args );
		$cat_args['taxonomy'] = 'question_category';

		$question_categories = get_terms( $cat_args );
		include ap_get_theme_location( 'addons/category/categories.php' );
	}

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