Importing Posts From Custom Sources Into WordPress

WordPressOver the past few days, I have been working on some custom scripts to import information from an older system into WordPress as a custom post type with a great deal of custom meta information. I quickly found the key to doing so is to use the wp_insert_post() function.

In my case, I am importing information from XML files into PHP arrays. I am then using an array_map() callback to pull the information out of the imported array, format it the way I want it, assign the appropriate keys to it and more. From there, I am using the wp_insert_post() function and the add_post_meta() function to push that information into the WordPress database.