WordPress.org

Support

Support » How-To and Troubleshooting » Importing MT Post ID

Importing MT Post ID

  • I’m importing from MT to WP, and I want to preserve the post numbers in my MT entries so the URLs will still work. I’m following import instructions provided by Dr. Bacchus, as cited in the Codex.

    But I’ve run into a snag. Dr. Bacchus recommends that you edit WP’s mt-import file so that the database query will import that post ID. In the new WP version 2.02, however, there is no place in the query to indicate what fields are being populated, the way you would in a normal SQL query.

    Here is the actual query that appears in the WP-2.0 mt-import file:

    $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
    $post_id = wp_insert_post($postdata);

    How do I modify this query so that it will insert a custom post id?

    If this were a standard SQL query, I would know how to modify it. But since it seems to be a proprietary querying system, I’m worried about mucking something up.

    Thanks in advance for any help.

    Joshua

Viewing 9 replies - 1 through 9 (of 9 total)
  • I tried myself to modify it, with no success. There’s a function called wp_insert_post that need to be modified but I’m not a PHP geek to do that successfuly. Does anybody knows that to help us? And, of course, there’s also the fact of the tags still being stripped from the posts’ body.

    Any ideas?

    Problem solved.

    I customized the import script (to define and use a modifiction of the wp_insert_post function) to suit my needs, and it seems to have worked.

    After I finish launching my new blog, I’ll write an entry about my import process, and make my script available to anyone else who has a similar problem.

    I’m in an anxious wait! Hope you post here soon!

    Okay, here’s the short answer:

    1. Modify your MT export file in accordance with the instructions provided by Dr. Bacchus.

    2. Then rename the file mt.php (inside the wp-admin/import/ folder) to something like mtORIG.php and then replace it with my revision of this same file.

    3. Then go into your WP admin and conduct an import like you normally would.

    I can’t make any guarantees, but it certainly worked for me.

    If you have any ‘test’ posts in your current WP installation, you’ll want to delete them first, in case the files you’re about to import have the same ID number that those posts did.

    It sure worked for me too. Thanks a lot! I think everyone using MT are gonna thank you for this patch! Now, let’s blog again!

    Okay, I have posted full instructions now. The Codec’s old instructions for doing this no longer apply in a WP2.0+ world, so I’ll go update the MT import FAQ in the Codex as well.

    UPDATE: Oops, looks like I don’t have the authority to make that edit. Here’s the link to the relevant passage in the documentation, for anyone who has the authority and is willing to make the change. Would be helpful to have this information in the Codex.

    The relevant passage of the Codex still hasn’t been updated. I am sure that many former MT users would appreciate having it updated. Can someone please take care of this?

    I’ve wrote your URL to the Codex and I think people are gonna start visiting your site for this solution 🙂

    The relevant passage of the Codex still hasn’t been updated. I am sure that many former MT users would appreciate having it updated. Can someone please take care of this?

    Go for it! At the top of the codex page is a link to register. I registered last night and updated some other areas, pretty simple to do.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Importing MT Post ID’ is closed to new replies.