Can I reset post counters for categories?
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?
Leave an answer