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
- How can I hide a category from Contributors in the edit/add new post screen?
- Category page doesn’t use category.php, instead it redirects to homepage
- Multiple post categories – single permalink
- Delete a specific category when deleting a user
- 404 error on subcategory pages
- Add line breaks in Category description via enter
- View category in the preview of Theme Customizer
- Display only the latest post from multiple categories
- Mass/Bulk assign categories to posts
- how do I filter single_cat_title to remove all instances of a particlular word
- WordPress order categories by ID
- ACF: Display category name using taxonomy field
- Shortcodes not working in category or tag description
- Post in multiple categories
- Mod_Rewrite to show only last subcategory in URL
- wp_dropdown_categories() scripts working erratically on sidebar
- Hide subcategories (widget)
- Access current post parent and sub category
- How to exclude the last post from a category(featured for example) from the main loop?
- How to rewrite the post URL according to the category?
- Sticky post for each category on category pages [duplicate]
- get parent category only
- Question on using custom structures for categories
- new WP_Query all post in a category inside the loop
- How to add orderby parameter for sorting on category.php
- delete category name in the pages
- How to show only the name of one category above each posts in frontpage?
- Multiple categories for one menu item?
- Remove category link
- javascripts files not linking to my category slugs?
- Pretty URLs with Categories and Tags
- Select posts that match multiple category names, must match all categories listed
- How can i display category title over thumbnail?
- Need help with major category and permalink re-organization
- Include home page template in specific category template
- How to use category slug with a regular page
- Display all categories but only if they have posts in them that have a specific tag assigned
- Show audio player only in specific post type category
- Modifying category order
- display current portfolio categories from a specific parent
- how to get only grandchild category from a child category
- How to hook into creating a category?
- Media Library Category Exclude Tree
- show posts in archive page based on selected catagory
- How to display child-category PAGES on a category page
- How get all media from a posts category by db?
- Get the categorie name of Event Organiser plugin [closed]
- get_categories returns top-level categories instead of child categories
- Show posts from all categories
- Display the category name of a post that is in two different categories
- how to Specifies an author / editor to edit one category only?
- (WordPress) How to get custom taxonomy parent name?
- Show one same template for two category
- My Query is getting the wrong data
- Search functionality with multiple categories
- Make a menu visible for a single category and it’s content
- WordPress Loop Prob
- Display post content from category name using ajax
- WooCommerce category display in custom page
- How to display the category featured images [closed]
- how do I exclude a category foreach