It might be you’re using the category on a custom post type, in that case category_count
won’t include those. There’s another handy value on the $category
-object however: $category->count
. Try replacing this:
$postcount = $thiscat->category_count;
with this
$postcount = $thiscat->count;
The count attribute includes custom post types as well if the custom post type uses standard categories.1
Related Posts:
- Loading scripts only if a particular shortcode or widget is present
- Add class to before_widget from within a custom widget
- Is there any way to dynamically alter widget titles?
- How to use is_active_widget?
- Show post tags in a widget
- Add filter to blogroll widget
- Widget Options Not saving
- Embed iframe or html page into dashboard widget
- Where to find the source code of a widget?
- How to add author details in the post sidebar?
- Woocommerce Product Category Widget – hide categories that have no products in stock [closed]
- Why will using __construct instead of widget_class_name when creating widget trigger out of memory error
- Role that can edit only widgets, not other theme options
- When to use which plugin output method?
- Hooking Into Widget Output Loop
- Hide widget to non-logged in users without plugin (functions.php) [closed]
- How to add css classes to widgets using functions.php?
- WordPress: Apply filter/hook to a particular sidebar widgets?
- How can I add a new CSS class to a widget?
- wordpress widget textbox in the sidebar
- parse json object and display live in wordpress php widget
- How to get sidebar’s content inside admin-ajax?
- Widget – Store and update data
- passing variables inside a widget add_action
- Run JS after widget settings are saved?
- Text Widget Links Not Working
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- Add description to custom text widget and display the 5 recent post titles
- Add individual tag to widget title in sidebar
- Where do I save widget code for wordpress?
- Is there any way to print a widget by having its id?
- How to save widget fields generated from an array?
- Remove image height/width attributes from Image Widget
- Need help using a filter on the default Categories widget
- How to display an RSS feed widget inside a page?
- widget dropdown menu code
- Newbie: Help with Vertical Spacing on Footer Widget [closed]
- custom widget does not saved value
- php to add a link into wp widget without specific url
- Widget Select Options not saving
- How to call widget by widget’s id?
- Why is my custom widget breaking another one?
- in_widget_form detect sidebar id
- Shortcode not working in widget
- How to get options of all active widgets ?
- How to pass a special CSS class into widget li
- Show Woocommerce Product “attributes/extra information tab” in widget [closed]
- How to use the widget area to extend the page content?
- wordpress widget missing jquery
- Display a widget on a specific type of archive
- Add a specific css to a widget
- Widget Title is not saving in backend
- Add class to on sidebar widget
- Save button is not working on custom widget
- WordPress update not saving
- WordPress Edit Button not appearing for widget in customizer
- WordPress database error – quick review
- Select two value from meta key and post meta
- using get_template_part() inside a widget and passing variables
- How to add a text widget on the posts admin page?
- Widget select option not saving
- How do I exclude portrait pictures from the nextgen gallery sidebar widget?
- Add html after the first widget in a sidebar
- Changing the order of widgets according to current page?
- How to remove date in Recent Post widget?
- Your theme has 8 widget areas, but this particular page doesn’t display them
- A message to clients in the dashboard widget received from another site
- How to get individual values from custom widget?
- How would you return a value from an individual field in a custom widget?
- Widgets are not displaying in my theme
- Can view Social Media buttons only in the private mode – why?
- Before_widget won’t show up
- Widget Registration Problem
- Reload widget with AJAX
- Function for widget titles
- Widget outputting JS as plain text
- How do you add a widget to the side of a page
- Prevent widgets from disappearing when swtiching from parent to child theme
- How to show Widget in Content Bottom part on home page in twenty sixteen theme
- Widget settings disappear after refreshing page
- Widgets Opening In New Window – Unwanted
- Randomizing the RSS Widget
- Target logic based on Widget / Sidebar Name
- Allow end users to change settings of a widget
- Get widget locations in WordPress plugin
- Why is the phone number a hyperlink on desktop sites, in my widget?
- Widget checkbox array empty on update function
- how to use get_field_name in external ajax handler
- Add custom class to a tags [closed]
- Widget page broken
- wordpress random widget widget
- WooCommerce Layered Nav Widget [closed]
- How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]
- How to exclude a widget from showing up on a page?
- jQuery “on” handler does not fire on newly inserted widgets [closed]
- How to find the exact widget details
- Widgets are not showing after moving domain
- Keeping shortcode-generated widget and theme element in one line [closed]
- Can’t edit the widgets sidebar or footer