editing import-mt.php for misused fields
-
I’m trying to import my MT blog and it’s tricky because I misuse some fields in MT (intentionally) and that’s messing up my import. I need to edit import-mt.php so that the MT body becomes the WP excerpt. I need the MT extended body to become the WP body. I’ve tried messing with the labels in my import.txt file and editing import-mt.php accordingly, but nothing seems to work.
In my import.txt, I’m changing the “BODY” label to “SOURCE” (this is my made up field) for all entries (using find & replace). I’m changing “EXTENDED BODY” to “BODY”. I’m inserting a blank section for EXTENDED BODY below the BODY section for each entry. In effect, I’m adding an extra section, for my “source” field, above the BODY section. Meanwhile, in import-mt.php, I’m simply changing…
// We want the excerpt
preg_match(“|—–\nEXCERPT:(.*)|s”, $post, $excerpt);
$excerpt = addslashes(trim($excerpt[1]));
$post = preg_replace(“|(—–\nEXCERPT:.*)|s”, ”, $post);
…to…
// We want the excerpt
preg_match(“|—–\nSOURCE:(.*)|s”, $post, $excerpt);
$excerpt = addslashes(trim($excerpt[1]));
$post = preg_replace(“|(—–\nSOURCE:.*)|s”, ”, $post);
The result I’m getting when I import is that WP successfully interprets my SOURCE section as the excerpt but displays the whole remains of the entry, including the “BODY” marker and the “EXTENDED BODY” and all the dashes, as part of the excerpt. I can confirm this by going to edit an entry — the whole string from import.txt, including all the stuff for BODY, is in the excerpt field. In other words, during the import WP doesn’t stop reading import.txt for the excerpt at the dashes above the BODY label, as I would expect. Because I don’t know the exact meaning of the code above, I’m not sure where I’m going wrong.
BTW, the reason I don’t simply edit import.txt to move the string for the BODY section down to the EXCERPT section, and the string for EXTENDED BODY up to BODY is because I can’t think of a way to do that with find & replace and I have about 1000 entries to migrate. That would require somehow leapfrogging the strings over one another in the text file.
- The topic ‘editing import-mt.php for misused fields’ is closed to new replies.