I am using a script to import my vbulletin forum posts into wordpress as posts.
One quick issue I ran into is there are numerous forum posts with the same title ‘please help me’.
When I go into the post edit screen the permalink will show ‘please-help-me-2’ for the second one, and ‘please-help-me-3’ for the third one. That is exactly what I expect.
However, when you go to view the second one on the front end of the website, instead of having the -2 appended to the end of the url, it simply says ‘please-help-me’.
If I ‘update’ the post, then the permalink saves properly and the front end link changes like it should.
What I need:
Is there a function that I can use to go through the posts database and have it automatically ‘update’ all the posts so that the permalinks will change properly on the front end?
*we’re talking 1.25million posts here, so automation is important.
thanks
There is a function called wp_insert_post that takes a parameter for post ID. If the post ID is an ID that already exists, this function will update the post with the information you pass in the function parameters. I think using that function you could find a way to retrieve all of your post ID’s in an array and then use a foreach loop to update each one.