I would like to add the Taxonomy term "Michael Jordan" to every published post that has the text "Michael Jordan" somewhere in its post title.
I assume you should be able to do this via MYSQL injections using PHPMYADMIN with the right query. However Wordpess's database tables for taxonomies and terms is a bit complicated for my level of MYSQL.
I can select all the posts from the wp_posts table with the term "Michael Jordan" using.
SELECT * FROM `wp_posts` WHERE `post_title` LIKE '%Michael Jordan%';
I assume I would use the Post IDs from this result, to identify which posts to add the Taxonomy term.
Thank you for help with forming the right query.
First, take a backup of your database before proceeding.
term_id
for your term "Michael Jordan"select * from wp_terms where name="Michael Jordan"
, which should give you similar outputNote the
term_id
(yours will be a different number)INSERT INTO wp_term_relationships SELECT id,term_id_noted_on_step_1,0 FROM wp_posts WHERE post_title LIKE '%Michael Jordan%'
Just in case you'd like to go the WordPress route, check wp_set_object_terms