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
Earn Money
Recent Posts
- NETGEAR WN311B RangeMax Next Wireless-N PCI Adapter
- TRENDnet 300Mbps Wireless N USB Adapter ( TEW-624UB Version 1.0R)
- TRENDnet TEW-644UB Version V1.0R Wireless N USB Adapter
- SMC SMCWGBR14-N Barricade N ProMax Draft 11n Wireless Gigabit Broadband Router
- TRENDnet 300Mbps Wireless N PCI Adapter ( TEW-623PI Version 2.0R)
- MSI Wireless-N 1T1R USB2.0 Adapter
- TRENDnet TEW-633GR 300Mbps Wireless N Gigabit Router