Wordpress Import Fix for Post Excerpts

Tuesday, December 18th, 2007 | Lessons Learned

I migrated the contents of a wordpress blog into a new home by using the built in import/export of Wordpress 2.3.1 however, I found out that the exported xml data does not include “<excerpt:encoded>”. Moreover even if you encode the excerpt manually on the xml file, wordpress would not import the data enclosed.

I found this fix by Helli. It would require manual editing of wp-admin files, specifically wp-admin/export.php and wp-admin/import/wordpress.php.

 

In wp-admin\export.php

<description></description>

<excerpt:encoded><![CDATA[<?php echo $post->post_excerpt ?>]]></excerpt:encoded>

<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>

in wp-admin\import\wordpress.php 

   $post_author    = $this->get_tag( $post, 'dc:creator' );

   $post_excerpt   = $this->get_tag( $post, 'excerpt:encoded' );
   $post_excerpt = str_replace(array ('<![CDATA[', ']]>'), '', $post_excerpt);
   $post_excerpt = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_excerpt);
   $post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
   $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);

   $post_content = $this->get_tag( $post, 'content:encoded' );

I made the necessary changes in my Wordpress 2.3.1 installation and it worked great.

No comments yet.

Leave a comment

PowWeb Hosting - Only $3.88 per month Reliable Windows Web Hosting

Search