Tags::tags_page()
Description #
Tags page layout
Source #
File: addons/tags/tags.php
public function tags_page() { global $question_tags, $ap_max_num_pages, $ap_per_page, $tags_rows_found; $paged = max( 1, get_query_var( 'paged' ) ); $per_page = (int) ap_opt( 'tags_per_page' ); $per_page = 0 === $per_page ? 1 : $per_page; $offset = $per_page * ( $paged - 1 ); $tag_args = array( 'taxonomy' => 'question_tag', 'ap_tags_query' => true, 'parent' => 0, 'number' => $per_page, 'offset' => $offset, 'hide_empty' => false, 'order' => 'DESC', ); $ap_sort = ap_isset_post_value( 'tags_order', 'count' ); if ( 'new' === $ap_sort ) { $tag_args['orderby'] = 'id'; $tag_args['order'] = 'DESC'; } elseif ( 'name' === $ap_sort ) { $tag_args['orderby'] = 'name'; $tag_args['order'] = 'ASC'; } else { $tag_args['orderby'] = 'count'; } if ( ap_isset_post_value( 'ap_s' ) ) { $tag_args['search'] = ap_sanitize_unslash( 'ap_s', 'r' ); } /** * Filter applied before getting tags. * * @var array */ $tag_args = apply_filters( 'ap_tags_shortcode_args', $tag_args ); $query = new \WP_Term_Query( $tag_args ); // Count terms. $tag_args['fields'] = 'count'; $found_query = new \WP_Term_Query( $tag_args ); $tags_rows_found = (int) $found_query->get_terms(); $ap_max_num_pages = ceil( $tags_rows_found / $per_page ); $question_tags = $query->get_terms(); include ap_get_theme_location( 'addons/tag/tags.php' ); }
Expand full source code Collapse full source code View on GitHub: addons/tags/tags.php:106
Add your comment