[wp-hackers] How can I filter on post count for categories?

Austin Matzko if.website at gmail.com
Thu Jun 4 06:40:34 GMT 2009


On Thu, Jun 4, 2009 at 1:23 AM, L'Autre Monde<autremonde75 at gmail.com> wrote:
> Ok so I looked at this. My issue isn't really to count the number of items
> but rather to have my count took into consideration. I haven't managed to
> plug on a place where I can modify on the fly the number when a page
> containing the category list widget is generated.

I guess I misunderstood what you're trying to do.  If you're talking
about the category widget that prints wp_dropdown_categories(), you'll
need to redefine that widget with wp_dropdown_categories() such that
its "hide_empty" argument is set to 0.

The reason is that by default "hide_empty" is true, meaning that only
those categories will show up that have a positive count of associated
objects.  For each taxonomy, that count gets incremented by a callback
as determined when the taxonomy is defined.  For example, the
"category" taxonomy for object_type "post" calls
"_update_post_term_count" as the "update_count_callback."  Since each
taxonomy specifies its object type and you're using a custom object
type, probably there is no associated "update_count_callback," and the
count stays at zero.


More information about the wp-hackers mailing list