Support » Fixing WordPress » category_count not updating

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ParoXsitiC

    (@paroxsitic)

    Upon playing around it seems the category_count only counts published posts, and not pending posts. How can I have it so all posts published or not display with category_count, or as an alternative – what SQL can I run to get a internal count of all posts without modifying the category_count() function?

    Thread Starter ParoXsitiC

    (@paroxsitic)

    I figured out what I wanted to do by doing:

    $category_id = 52; // Your catID
    $term = get_term_by('id', $category_id , 'category');
    
    echo (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND term_taxonomy_id = %d", $term->term_taxonomy_id ) );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘category_count not updating’ is closed to new replies.