Wordpress category post count wrong

25 Views Asked by At

I’m working on updating the blog I started about my daughter before she was born and she’s 13 now. When I started, it didn’t occur to me to set up post categories so visitors could just to link to the posts for the right year. Over time I accumulated 857 uncategorized posts…

I couldn’t find a plugin that would let me assign categories to posts based on date, so with some help I put together an SQL statement that does just that:

UPDATE wp_term_relationships
SET term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_rfowje_term_taxonomy WHERE term_id = '20')
WHERE object_id IN (
SELECT p.ID FROM wp_posts p
WHERE p.post_date LIKE '2009%' AND p.post_status = 'publish'
)
AND term_taxonomy_id = (
SELECT term_taxonomy_id FROM wp_term_taxonomy
WHERE term_id = (SELECT term_id FROM wp_terms WHERE name = 'Uncategorized')
);

This works quite well, and I can see in the WP UI that the posts are no longer ‘Uncategorized’ and are now ‘2009’. The thing I can’t figure out is that when I tell the sidebar widget to show post counts for the categories … the count is clearly wrong.

You can see this on the live site: http://babyup.tikimojo.com The widget on the right lists the categories – with the current theme the post count is under its respective category.

It’s not a terribly big deal, but I like to get things right. Seems like there’s another place where something has to change to get the post count right. Any idea what that is?

WordPress 6.4.3

Thanks for your help,

0

There are 0 best solutions below