To connect to your WordPress blog and copy all posts, you can use the python WordPress XML-RPC library python-wordpress-xmlrpc
. To install this library, run the following command in your terminal:
pip install python-wordpress-xmlrpc
Once you have installed the library, you can use the following code to copy all the posts from your old blog to the new blog:
pythonfrom wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
# Set up the client for the old blog
old_blog_url = 'https://evert.cloud/xmlrpc.php'
old_blog_username = 'your_old_blog_username'
old_blog_password = 'your_old_blog_password'
old_blog_client = Client(old_blog_url, old_blog_username, old_blog_password)
# Set up the client for the new blog
new_blog_url = 'https://evertslabs.com/xmlrpc.php'
new_blog_username = 'your_new_blog_username'
new_blog_password = 'your_new_blog_password'
new_blog_client = Client(new_blog_url, new_blog_username, new_blog_password)
# Get all the posts from the old blog
old_posts = old_blog_client.call(GetPosts())
# Copy the posts to the new blog
for post in old_posts:
new_post = WordPressPost()
new_post.title = post.title
new_post.content = post.content
new_post.date = post.date
new_post.post_status = post.post_status
new_post.terms_names = post.terms_names
new_post.custom_fields = post.custom_fields
new_blog_client.call(NewPost(new_post))
Make sure to replace the old_blog_username
, old_blog_password
, new_blog_username
, and new_blog_password
with your actual usernames and passwords. Also, replace https://evert.cloud/
and https://evertslabs.com/
with your actual blog URLs.