Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Migrate Ghost to Wordpress
* A Wordpress Blog
* Ghost export file (json).
* Python Packages: python-wordpress-xmlrpc
>>> pip install python-wordpress-xmlrpc
If your have any questions, please comment here below.
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
from dateutil.parser import parse
from time import sleep
import json
xmlrpc_endpoint = ''
username = ''
password = ''
wp = Client(xmlrpc_endpoint, username, password)
filename = 'ghost.export.json'
with open(filename) as f:
text =
data = json.loads(text)
for p in data['db'][0]['data']['posts']:
print p['title']
date = p.get('published_at', None)
if date is None:
post = WordPressPost()
post.slug = p['slug']
post.content = p['html']
post.title = p['title']
post.post_status = 'publish'
try: = parse(date)

This comment has been minimized.

Copy link

adlerdias commented Oct 1, 2015

I had to change:

for p in data['db'][0]['data']['posts']:


for p in data['data']['posts']:

Thanks, it saves me a lot of time


This comment has been minimized.

Copy link

eidmantas commented May 26, 2016

Hey @tzangms, I used your script, edited a bit and wrote a small blog post( ) , since I just needed to do a migration. I hope that's okay with you! TYVM for the help, it helped a lot.

Too bad I don't have time study JSON outputs of different Ghost versions, I bypassed stuff with except: exit for the time being. Creation date info was lost.


This comment has been minimized.

Copy link

kstrauser commented May 1, 2017

Thanks for this! I modified it a little to copy tags, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.