WordPress bulk modify post catgories
One thing I need to do in Wordpress that I have not found is how to bulk modify categories in bulk. I have a few hundred posts sitting in the Uncategorized Category. To edit them now, you have to do into the Admin page, select posts by Category, select the type Uncategorized from the drop down, and they one by one edit the post, chaneg the category, save the post, then start over again. Not a fun process.
I have searched on the web and posted on the WordPress forums, but no luck on a solution.
So lets walk through the SQL to do it ourselves
Lets see what categories we have
SELECT *
FROM wp_3_categories
Now lets see what the post structure looks like -
SELECT *
FROM wp_3_posts
WHERE post_category = 0
So the next step is lets see if we can pull out posts that have a keyword in the content of the title. In this case, I have a number of posts from ORIGINS 2006 that would all be Gaming category posts.
SELECT *
FROM wp_3_posts
WHERE post_category = 0
AND post_title LIKE `ORIGIN`
This query fails, and I need to find out why. so I stepped back and tried this -
SELECT `wp_3_posts`.`post_title`
FROM wp_3_posts
WHERE (`wp_3_posts`.`post_title` %ORIGIN%)
And that fails, so I started searching for the right syntax to do a text query on any record that has a column that contains a text string anywhere in that column.
SELECT *
FROM wp_3_posts
WHERE ‘wp_3_posts’.'post_title’ LIKE ‘%ORIGIN%’
Failed, so I went looking for a simple SQL search example and found this -
SELECT * FROM Persons WHERE FirstName LIKE ‘O%’
Still trying to figure out why mine did not work, I tried this -
SELECT * FROM wp_3_posts
WHERE post_title LIKE ‘%ORIGIN%’
BINGO, I have results. So now to convert my query into an update on two tables, the wp_3_posts table and the wp_3_post2cat table
Popularity: 3%
Leave a Reply
You must be logged in to post a comment.