Add this code to your functions.php file and it will remove the parentheses and surround the post count with a span with a class to easily style it.
function categories_postcount_filter ($variable) {
$variable = str_replace('(', '<span class="post_count"> ', $variable);
$variable = str_replace(')', ' </span>', $variable);
return $variable;
}
add_filter('wp_list_categories','categories_postcount_filter');
++Bonus
In the archive widget, if you checked “Show posts count” checkbox you’ll see the same parentheses around posts count, here’s another filter to remove them and add a class to easily style theme.
function archive_postcount_filter ($variable) {
$variable = str_replace('(', ' ', $variable);
$variable = str_replace(')', ' ', $variable);
return $variable;
}
add_filter('get_archives_link', 'archive_postcount_filter');
Related Posts:
- Using wp_category_checklist in a widget
- How to create a widgetized sidebar for every category dynamically?
- Customizing Default Categories Widget
- Display all posts with same title
- I want to create a posts widget and be able to select categories
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- Categories lose hierarchy order once assigned to post
- Add Icons to the Product Category Sidebar Widget WooCommerce
- How to display widgets inside a page content without a plugin?
- How do you categorize pages?
- WordPress category widget only show categories with children
- Customize WordPress widget – Product Category
- Post Count for Categories, however not to calculate a total
- How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
- Categories widget show empty?
- Is it possible to remove from default category widget?
- how to remove the default title of Categories widget
- How to show 5 posts from specific category on related page?
- display a widget on specific category and its sub categories
- Multiple selection for wordpress widget
- How to not display subcategories in Recent Posts widget area?
- How to Sync Menu, Widgets and other masters from Main Website to its Sub Site
- Tags Instead of Category
- How to hide widget from certain category
- Last x Posted Categories?
- WordPress category filters as subcategories
- exclude certain categories form archive widget
- Conditional widget for theme template file
- Add filter for specific category only
- Exclude a category from block editor’s category widget
- How can I display the category name in the single post when using WP Blog and Widget?
- How to Change Sort Order of default WordPress Catgory Widgets?
- How to add an “All” category to the tag cloud?
- Custom file with special code of category widget
- in_category(‘category-sluga’) returns true for Archive page of Category ‘category-slugb’
- Problem with single posts not showing correct category sidebar
- How To Disable Category Hierarchy In Categories Widget?
- single category widget with conditional terms
- Customize category query in widget
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Adding Colorpicker Field To Category
- Different templates for parent and children categories/taxonomies
- Remove child products from woocommerce category page [closed]
- Display comments on a comment page without form
- Get a list of commas separated categories inside a loop
- Plural Category Base Slug On Category Archive Page
- How do I view a feed consisting of posts from multiple categories?
- Marking old posts as no longer relevant
- Alphabetizing Posts in a Category Page?
- Unpublish all posts in a category
- Add class to items in wp_list_categories()
- How is the single category page called and how does it know which posts to show?
- How to export/import categories and keep their IDs?
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- How to make a Thumbnails Mosaic
- wp_parse_args & category parameter
- Extract image url associated to a category
- category filter doesn’t work in WPML
- List Sub-Categories of a Parent Category
- add text to the top of category page
- Order of subcategories
- “Categories” for six authors [closed]
- Category control subcategories
- How to make the link to the category for a post go to corresponding page number in archive?
- How to build a simple nav system of custom post type categories and its posts?
- Style category link depending on category ID
- How to insert category list into post creation page, and retrieve chosen categories?
- Shortcode interpreted as text
- scaleability of tags
- Having problems with paging
- Dropdown menu for subcategories
- “All posts” in the category widget
- Adding custom ID field to the categories
- Getting Category Children
- Child Category Conditional Question
- Break down output of wp_list_categories
- Get the ID of the current post’s child category
- get category name in admin screen
- Return category posts with WP_Query
- Include specific category in URL automatically
- WordPress Category Page Layout
- get_the_category – display only a single category for a post (not all categories)
- It is possible to display related posts from same category as the current post?
- Categories are not available AT ALL under Menus
- Create categories manually in database
- Displaying a Category on a WordPress Page
- Hide specific category link from showing
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Display List of Categories Within a Custom Taxonomy
- add custom option to get_categories dropdown
- Category as subdomain
- How to use in_category?
- Categories as selectable links on submission form
- Displaying categories and subcategories without link
- Replace the post count on wp_list_categories with “Has Posts” instead of number and “No Posts” if none
- exclude category in loop.php
- WordPress portfolio how to change “ALL” category by one other category that I created?
- How to hide my categories pages’ names, and how as well to reduce the space beween my sidebar’s widgets?
- Different number of posts in regular loop and CPT category page