Copy Categories to Tags – The Plugin
Part 2 of the previous Wordpress Tag Post
In my continuing effort to duplicate existing categories associated with posts as tags, I offer up this plugin. Remember, my goal is to phase categories out in favor of tags. So I don’t want to do just an abrupt change over switching my categories to tags. Instead, I want to duplicate them, and transition away from categories. First in the templates, then cleaned out of the database.
Here’s the process:
For each post, get a list of the categories. For each category, determine if the category (term_id), exists in the wp_term_taxonomy table. If it does, it will have the taxonomy of “post_tag”
Does the category already exist as a post_tag?
If Yes
Retrieve the term_taxonomy_id for that term, and insert it into wp_term_relationships. Also, update the count in the wp_term_taxonomy table for that post_tag – important for tag clouding.
No
Create a new record in the wp_term_taxonomy table referencing the same term_id but with a taxonomy of post_tag. Set the count to 1 on insert.
In either case:
Retrieve back the term_taxonomy_id, and insert that into wp_term_relationships for the post.
-
Tracy
-
skiaddict
-
Herr Rau
-
Josh Kenzer
-
charlie
-
Herr Rau
-
Josh Kenzer
-
Wolfy
