Create slugs programmatically

I’m updating programmatically posts in a WP 3.01 install, using custom made tools.
Sometimes I do change programmatically post_status from DRAFT to PUBLISHED using custom SELECT queries, however this seems spoiling posts permalinks.

When in a DRAFT state, posts have the following link structure

http://myblog.com/?p=73006

Could there be some “trick” to force a change in the link structure, generating the proper permalink?

2 Answers
2

You need to programmatically set the slug as you do so. An SQL trigger could do the trick. Don’t forget to mind duplicate slugs as you write it.

Else, instead of publishing using the database, write a php script that calls the WP API.

Leave a Comment