Short description: I've created a bunch of terms and attached them to an existing taxonomy for a certain custom-post that already exist using the SQL code below. After doing this I'd like to update wp_term_taxonomy.count . I set it to 0 (dumb?) so the new terms are not appearing in search forms (they do appear on the individual custom post though). Setting count to 1 fixes this but still 'wrong' and I'm worried this could cause issues down the line.
Answers within SQL or Wordpress will work though my coding is just above n00b status.
My solution: set wp_term_taxonomy.count to 1 for new terms so it'll appear across the site. I can use them in searches (important) but things like tag clouds are wrong/mis-sized (fine) and I'm worried I'll run into unknown issues.
Details: I am adding many terms to a taxonomy I have already created called 'csf_brand' for a custom post type called 'jeans'. Rather than editing each of several hundred custom posts already created I thought I'd batch them with SQL, using the 3 tables related to custom taxonomies.
First I create my new terms.
INSERT INTO `wp_nhyb_terms` (`term_id`, `name`, `slug`, `term_group`) VALUES (10, 'GAP', 'gap', 0); --there's a bunch more lines like this adding in new terms
Next, I attach my terms to the appropriate taxonomy. 0 is not the right count but calculating this is not something I'm interested in doing if I can avoid it.
INSERT INTO `wp_nhyb_term_taxonomy` (`term_taxonomy_id`, `term_id`, `taxonomy`, `description`, `parent`, `count`) VALUES (10, 10, 'csf_brand', '', 0, 0); --Here is where I could use 1 instead of 0
Finally, I attach the terms to my custom post types by the post ID (object_id)
INSERT INTO `wp_nhyb_term_relationships` (`object_id`, `term_taxonomy_id`, `term_order`) VALUES (125, 10, 0);
And that works. But wp_term_taxonomy.count is not 0 so they aren't appearing in my searches (e.g. I have a page that can search for brands via dropdown and they aren't an option). If I edit a custom post in my browser then save it recognizes the new term and corrects the count. But that's not a great process since I'll eventually miss something.