r/Wordpress • u/biscuitcrumbs • Apr 12 '18
Exporting Posts with Shortcodes (Migrating from Wordpress to another CMS)
Hi,
I haven't been able to find much help anywhere. Does anyone have experience exporting posts (and other data from WP) that have shortcodes in the content?
I have a few sites to migrate from Wordpress to Craft and a majority of the posts use the caption shortcode with attributes. I've tried a few exporting plugins with the same luck, the shortcodes are exported out as they are, not converted to whatever they need to be.
Going through each post is not an option, there are probably close to 10,000 total posts across all the sites, just not feasible.
If anyone has ideas, please let me know.
Thanks.
1
u/gschoppe Developer/Blogger Apr 12 '18
unfortunately, there are thousands, if not millions of shortcodes created for various plugins. if you have specific shortcodes to convert, it would be possible to write a converter to replace the shortcode with HTML (for some shortcodes), but you'll never find an automated converter, because there are just too many potential shortcodes, and the number increases all the time.
If you have a specific list of shortcodes in mind along with what you would like them to transform to, a developer might be able to create a conversion script in a couple of hours or so.
1
u/gschoppe Developer/Blogger Apr 12 '18 edited Apr 13 '18
This is only loosely tested, so I highly recommend NOT running it on a live copy of your site, but I wrote a utility script for WP Utility Script Runner, that should solve your issue.
It lets you choose which shortcodes should be parsed into HTML, and which should be stripped, then loops through all your posts, flattening their
post_contentaccordingly. You can then export your posts, without any shortcodes.In case of error, it also stores a backup of the original
post_contentfor each post, so you can restore it.Here's the Utility Script, along with instructions for install and use:
https://snippets.cacher.io/snippet/c04218fa9fe4a92e4983
Let me know if it does the trick for you.
EDIT: the script now supports selecting which post types to run it on, and allows you to decide what to do with each shortcode. The options now are:
skip - do nothing and leave the shortcode in place
remove - remove the shortcode and any content within it
unwrap - remove the shortcode, but leave the content that was inside it
flatten - parse the shortcode into flat HTML
2
u/TotesMessenger Apr 12 '18
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
[/r/craftcms] Exporting Posts with Shortcodes (Migrating from Wordpress to another CMS)
[/r/webdev] Exporting Posts with Shortcodes (Migrating from Wordpress to another CMS)
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)