I am copying some content between another CMS and Wordpress. I need to keep track of the original Id because I might have to update the copied content in the future. The old CMS will still be used for some time since users still need to learn WP.

I am currently using metafields for this, but this obliges me to make updates to two different tables in the database (the posts and the meta). I would rather prefer to just update once using some alternative field in the post table.

For the amount of articles I have to copy the impact is not neglectable at ll.

1 Answer 1


It depends on how are you importing those posts. You can use wp_insert_post() with import_id:

$postToBeInserted = array(
    'post_title'    => 'Your Post Title',
    'post_content'  => 'Your post content...',
    'import_id'     => 154


If there is no post with the specified import_id the post will have that ID. That way you won't have to deal with meta fields and all migrated posts will have the same ID as in the previous CMS. Although there is a drawback because it can lead to potential collisions if you continue to post new posts in the old CMS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.