WordPress.org

Ready to get started?Download WordPress

Forums

Importing Custom Fields From MT Formatted File Into WP (2 posts)

  1. bplevyak
    Member
    Posted 7 years ago #

    I've created a Movable Type looking import file from my old Coranto blog. I have a custom field that I've given its own like in the MT import.txt file. Like so:

    CATEGORY: news
    STATUS: publish
    MYFIELD : stuff goes here

    What I'm trying to to is get the data in "MYFIELD" to go into the proper custom field of that post. I titled it MYFIELD in wordpress as well. I figure I need to modify the case section of mt.php under the import folder, similar to:

    case: 'MYFIELD'
    XXXXXXXXXXX = $wpb->escape($value);

    What I dunno is what goes in that XXXXXXXXX there? How do I reference that post's custom field meta data in code and load into it?

    I could use a little help...Thanks!

    B.

  2. ccoupe
    Member
    Posted 7 years ago #

    You may want to get up to speed with PHP basic principles. There's a PHP tutorial or two just a google search away.

    XXXXXXXXXXX is a perfectly good variable name. Not the best one but it's your choice to make. Call it anything you like that isn't used already. double check the case: string may needs a colon "MYFIELD:. Or not

    Further down in that bit of code is where the extracted post variables are passed into another function that "waves hands" writes them to the database. That's where your magic really has to happen. Frankly, I'd avoid that approach without consulting a witch doctor and bring a bucket of dead chickens. IMO.

    I know nothing about custom fields in WordPress or MT so better solutions than this could happen. Can you map the MT custom field to be a (secondary) MT category? I'm not current on MT templating but it seems possible. The WP mt.php importer does fine with multiple CATEGORY: entries in MT Format import files. You can build all the WP categories you want that way. Then it's a small matter of of "doing something" with the posts in that category after they are imported.

    I've you have a link to your website that shows the custom fields in action, we (the big we) might have other suggestions.

Topic Closed

This topic has been closed to new replies.

About this Topic