Improve tag cloud count filter
This commit is contained in:
parent
50b4e957e6
commit
5943ec72d2
@ -55,6 +55,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => 0.625,
|
'smallest' => 0.625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
@ -319,8 +319,14 @@ add_action( 'pre_get_posts', 'fictioneer_extend_taxonomy_pages' );
|
|||||||
* @return array Array of found terms with modified counts.
|
* @return array Array of found terms with modified counts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function fictioneer_exclude_non_stories_from_cloud_counts( $terms, $taxonomies ) {
|
function fictioneer_exclude_non_stories_from_cloud_counts( $terms, $taxonomies, $args ) {
|
||||||
if ( ! is_tax() || is_admin() || empty( $terms ) || empty( $taxonomies ) ) {
|
if (
|
||||||
|
! ( is_tax() || is_tag() || is_category() ) ||
|
||||||
|
is_admin() ||
|
||||||
|
empty( $terms ) ||
|
||||||
|
empty( $taxonomies ) ||
|
||||||
|
( $args['fictioneer_query_name'] ?? 0 ) !== 'tag_cloud'
|
||||||
|
) {
|
||||||
return $terms;
|
return $terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +337,12 @@ function fictioneer_exclude_non_stories_from_cloud_counts( $terms, $taxonomies )
|
|||||||
|
|
||||||
if ( ! empty( $matched_taxonomies ) ) {
|
if ( ! empty( $matched_taxonomies ) ) {
|
||||||
foreach ( $terms as &$term ) {
|
foreach ( $terms as &$term ) {
|
||||||
|
$term_ids = [];
|
||||||
|
|
||||||
|
if ( $args['pad_counts'] ?? 0 ) {
|
||||||
$term_ids = get_term_children( $term->term_id, $term->taxonomy );
|
$term_ids = get_term_children( $term->term_id, $term->taxonomy );
|
||||||
|
}
|
||||||
|
|
||||||
$term_ids[] = $term->term_id;
|
$term_ids[] = $term->term_id;
|
||||||
|
|
||||||
$count = $wpdb->get_var(
|
$count = $wpdb->get_var(
|
||||||
|
1
tag.php
1
tag.php
@ -63,6 +63,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => .625,
|
'smallest' => .625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
@ -64,6 +64,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => .625,
|
'smallest' => .625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
@ -64,6 +64,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => .625,
|
'smallest' => .625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
@ -64,6 +64,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => .625,
|
'smallest' => .625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
@ -64,6 +64,7 @@ get_header();
|
|||||||
<?php
|
<?php
|
||||||
wp_tag_cloud(
|
wp_tag_cloud(
|
||||||
array(
|
array(
|
||||||
|
'fictioneer_query_name' => 'tag_cloud',
|
||||||
'smallest' => .625,
|
'smallest' => .625,
|
||||||
'largest' => 1.25,
|
'largest' => 1.25,
|
||||||
'unit' => 'rem',
|
'unit' => 'rem',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user