[wp-hackers] Update Category Count after Bulk Delete
Nathaniel Taintor
goldenapplesdesign at gmail.com
Wed Mar 30 16:43:38 UTC 2011
Before doing bulk import/deletes, just call:
wp_defer_term_counting( true )
And after your import is finished, call
wp_defer_term_counting( false )
That will catch up your term and category counts after the delete. For the
comments, I think you have to add another JOIN to your SQL to catch all the
comments on the posts you're deleting.
Nathaniel Taintor, Designer/Developer
*Golden Apples Design*
http://goldenapplesdesign.com
@GoldenApples | 503.877.2880
goldenapplesdesign at gmail.com
On Wed, Mar 30, 2011 at 7:03 AM, Brian Layman <wp-hackers at thecodecave.com>wrote:
> On 3/30/2011 5:32 AM, Jason wrote:
>
>> Hey Guys,
>>
>> I need to bulk delete about 4k posts from a site - all the posts are
>> assigned to a specific category.
>>
>> Does anyone have any MYSQL snippets or pointers to something that will do
>> the job? I don't think WP Bulk Editing or any of the bulk delete plugins
>> will do the trick for such a large number of posts.
>>
>> So far I can bulk delete the posts using something like:
>>
>> *DELETE a,b,c,d FROM wp_term_relationships a
>> JOIN wp_term_taxonomy b ON b.term_taxonomy_id = a.term_taxonomy_id
>> JOIN wp_terms c ON c.term_id = b.term_id
>> JOIN wp_posts d ON d.id = a.object_id
>> WHERE c.name = 'Test Delete';* --Category Name
>>
>> But that still leaves the remaining category counts incorrect and comments
>> still in the system.
>>
>> Thoughts? Help...?
>>
>> Cheers
>> JC.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> update `wp_term_taxonomy` set `count`=(select count(*) from
> wp_term_relationships where
> `wp_term_taxonomy`.`term_taxonomy_id`=`wp_term_relationships`.`term_taxonomy_id`);
>
> and if you messed with comments:
>
> http://thecodecave.com/2009/01/07/fixing-wp-comments-per-post/
>
> --
> Brian Layman
> http://eHermitsInc.com
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list