Quantcast
Channel: User Michael - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 44

Answer by Michael for Don't show a tag on a post if it is the only post with that tag

$
0
0

you can try using a filter function (added into functions.php of your (child) theme), specific to your taxonomy 'topic':(based on https://developer.wordpress.org/reference/functions/get_the_term_list/ and https://developer.wordpress.org/reference/functions/get_the_terms/ )

// define the get_the_terms callback function filter_get_the_topic_terms( $terms, $postid, $taxonomy ) {    if( !is_admin() && $taxonomy == 'topic' ) : // make filter magic happen here...         $filtered_terms = array();        foreach( $terms as $term ) :            if( $term->count > 1 ) {                $filtered_terms[] = $term;            }        endforeach;        $terms = $filtered_terms;    endif;    return $terms;}// add the filter add_filter( 'get_the_terms', 'filter_get_the_topic_terms', 10, 3 );

Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>