ap_get_tag_filter( string|false $search = false )

Description #

Return category for sorting dropdown.

Parameters #

  • $search
    string | false (Optional) Search query. Default value: false

Source #

File: includes/taxo.php

function ap_get_tag_filter( $search = false ) {
	$args = array(
		'hierarchical'  => true,
		'hide_if_empty' => true,
		'number'        => 10,
	);

	if ( false !== $search ) {
		$args['search'] = $search;
	}

	$terms    = get_terms( 'question_tag', $args );
	$selected = ap_get_current_list_filters( 'qtag' );

	if ( ! $terms ) {
		return false;
	}

	$items = array();

	foreach ( (array) $terms as $t ) {
		$item = array(
			'key'   => 'qtag',
			'value' => (string) $t->term_id,
			'label' => $t->name,
		);

		// Check if active.
		if ( $selected && in_array( $t->term_id, $selected, true ) ) {
			$item['active'] = true;
		}

		$items[] = $item;
	}

	return $items;
}

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