Hi Matt,
The easiest way to do this with MySQL is to produce a ‘dummy’ post_name value. The post_name value simply has to be unique amongst the other post_name values in the records in your wp_posts table. There’s no benefit from WP’s point of view in it being derived from the post_title value – that’s just a convenient way for WP to derive the value.
So, if you’re okay with something like ‘post-1’, ‘post-2’, ‘post-3’ etc values for these particular records, do something like the following.
Disclaimer: please make sure you have a backup of wp_posts before proceding, and you know how to restore that backup. I won’t guarantee this will work, and I won’t guarantee that it won’t cause other issues. In other words, you get what you pay for, which is free advice. 😉
Assumptions: I’m assuming the records you’re having problems with have either a zero-length string or NULL value in post_name. I’m assuming each record validly contains a unique integer value in the ID field.
After reading the above, if you want to go ahead, issue the following:
UPDATE wp_posts SET post_name = CONCAT('post-', CAST(ID as CHAR)) WHERE LENGTH(post_name) = 0 OR post_name IS NULL
What this should do: the records with missing post_name values should now have a post_name value of ‘post-‘ with the unique id from the ID field appended. So, if the record in question had an ID value of 212, then post_name should now have the value of ‘post-212’.
Hope this helps. Feel free to ask questions if you’re uncertain how to procede.
Much warmth,
planetthoughtful
Thread Starter
ma2t
(@ma2t)
Hey there planetthoughtful,
Firstly, thanks you very much for your detailed and helpful reply :), very much appreciated. Although your idea would work, which is the main thing I guess, .. there is a problem, im very much in this game now for search engine optimization, and having the url’s that match the page title help, so this is what I am really going for, and one of the main reasons I changed to wordpres.
Thinking about this now, I guess I should have mentioned that in my first post, sorry for not saying.
Thanks you very much for your help though!
Thread Starter
ma2t
(@ma2t)
Hey there,
Just wanted to give an update so no one wastes their time 🙂
Im going to give the rss feed import a shot, that should work, assuming I can get past the 2mb file upload limit :/ lol.