Title: setting the permalink using wp insert post
Last modified: August 19, 2016

---

# setting the permalink using wp insert post

 *  [Jamil Jonna](https://wordpress.org/support/users/jonna/)
 * (@jonna)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/setting-the-permalink-using-wp-insert-post/)
 * Hello,
 * I’m attempting to migrate thousands of html/php pages into several wordpress 
   installations so the [wp insert post help page](http://codex.wordpress.org/Function_Reference/wp_insert_post)
   has been indispensable. But there seems to be one critical parameter missing 
   from the import array: ‘set permalink’.
 * In my case, I want the permalink set to the file name (e.g. 20100101foster.php)
   and I’ll also want to use another variable to insert the post title (i.e. go 
   to the “title” div and insert the title).
 * First, if it is possible to set the permalink on import, how do I do so?
 * Second, when setting the permalink, if my original URL had a .php or .html extension,
   will the URL work? If not, how do I make it work.
 * Third, I’d like to automate the process and use variables to pull in the permalink
   and title (and possibly tags); where do I start in creating this script?
 * Any help is much appreciated. Many thanks,
 * Jamil

Viewing 1 replies (of 1 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/setting-the-permalink-using-wp-insert-post/#post-1337622)
    1. I believe that the ‘post_name’ field in the ‘wp_posts’ table is the permalink‘
       slug’.
    2. You’ll probably need to strip the extension of convert it to something like ‘-
       php’.
    3. Yikes!. A function running in a theme’s functions.php should give you easy access
       to all of WP’s built in functions, which will greatly ease the insertion process.
       It seems to me that the hardest part will be parsing those html and php files
       to sort out the titles, categories, author, content, images, and such.

Viewing 1 replies (of 1 total)

The topic ‘setting the permalink using wp insert post’ is closed to new replies.

## Tags

 * [automate](https://wordpress.org/support/topic-tag/automate/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/setting-the-permalink-using-wp-insert-post/#post-1337622)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
