Skip to content

Instantly share code, notes, and snippets.

@greg-randall
Last active January 24, 2022 19:24
Show Gist options
  • Save greg-randall/fcd34b22a0337fe57154fa8592048255 to your computer and use it in GitHub Desktop.
Save greg-randall/fcd34b22a0337fe57154fa8592048255 to your computer and use it in GitHub Desktop.
Export all content from Wordpress but evaluate shortcodes before exporting.
I'm using this to get away from Enfold and Devi which marks everything up with hundreds of shortcodes. This will output ugly html, but at least it's html.
In wp-admin/includes/export.php change this line:
$content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
To:
$content = wxr_cdata( apply_filters( 'the_content_export', do_shortcode( $post->post_content ) ) );
After exporting your data, you should change it back. Modifying WordPress core files is not best practice.
I then run this gist that helps clean up the gross html output:
https://gist.github.com/greg-randall/1fd0176cba852a0d4942cdcbeb1a825c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment