WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to override default update_count_callback for category? The default function counts published posts while I want to count private posts. I do not want to register a new taxonomy.

share|improve this question
up vote 3 down vote accepted

In your update_count_callback function do a check for $post->post_status and don't increment your count if post_status is not private.

See this excellent answer on writing a custom update_count_callback callback function.


Misread the question. To override the existing default for the category taxonomy you can create a function that overrides the global $wp_taxonomies variable

function change_category_arg() {
    global $wp_taxonomies;
    if ( ! taxonomy_exists('category') )
        return false;

    $new_arg = &$wp_taxonomies['category']->update_count_callback;
    $new_arg->update_count_callback = 'your_new_arg';

add_action( 'init', 'change_category_arg' );
share|improve this answer
Thanks, but thats for custom taxonomy. I want to override categorys callback. I mentioned this in the question. – afnrf May 3 '12 at 6:32
@afnrf Category is a taxonomy. And you'll notice that he targets 'category' in his answer – Stephen Harris May 3 '12 at 8:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.