Can I reset post counters for categories?

Question

I’ve noticed my post counters in Dashboard - Posts - Categories are showing wrong values. For example, it shows a positive numbers in the Count column for categories, that have zero posts associated to them.

I’ve also noticed it displays the same numbers when I try to get them using:

$category = get_category($id);
$count = $category->category_count;
echo $count;

but when I try to query the posts from this category, using:

$args = array(
    'post_type' => 'post',
    'cat'       => $id
);
$query = new WP_Query($args);

I get zero results (which is correct).

It seems the native WP’s counters got somehow messed up. Is there a way to reset them and not mess up other things/IDs at the same time?

0
, , Kristian Filo 4 years 2020-02-19T08:39:14-05:00 0 Answers 60 views 0

Leave an answer

Browse
Browse