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

Answer by Michael for Remove parentheses from tag cloud count

$
0
0

this is an example output of an tag cloud widget element (wp4.8):

<a href="http://localhost/wp-beta-test/tag/handcrafted/" class="tag-cloud-link tag-link-327 tag-link-position-22" style="font-size: 8pt;" aria-label="handcrafted (2 items)">handcrafted<span class="tag-link-count"> (2)</span></a>

as you can see, the widget outputs some aria lable also using parentheses, which interferes with a simple string replace.the tag number including the parentheses is also already wrapped in a span.

for example, try to use:

function tagcloud_postcount_filter ($variable) {$variable = str_replace('<span class="tag-link-count"> (', '<span class="post_count"> ', $variable);$variable = str_replace(')</span>', '</span>', $variable);return $variable;}add_filter('wp_tag_cloud','tagcloud_postcount_filter');

Viewing all articles
Browse latest Browse all 44

Trending Articles



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