Ruby on Rails is really OOPs based framework. I personally love this framework. I worked on this for many years. Many Ruby lovers are looking to integrate the wordpress with Ruby on Rails. I strongly suggest to integrate wordpress with ROR using XMLRPC APIs. Using following code you can easily add the wordpress into Ruby on Rails Project. Use my following steps:

wordpress XMLRPC api integration with ruby and rails

Note: There are so many XMLRPC APIs provided by wordpress. I given the some simple example here.

First setup wordpress. Login to wordpress admin and enable the XMLRPC.
Go to Settings->writing and enable the XMLRPC checkbox.

wordpress XMLRPC api integration with ruby and rails
wordpress XMLRPC api integration with ruby and rails

Now you can fetch the wordpress posts, pages, tags etc.. using XMLRPC.

Following script is written in Ruby.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

require 'xmlrpc/client'

# build a post

#Use this for reference - ,

post = {
'post_title'       => 'Post Title',
'post_excerpt'       => 'Post excerpt',
'post_content'       => 'this is Post content'

# initialize the connection - Change

connection = XMLRPC::Client.new2('')  #Replace your wordpress URL

# make the call to publish a new post

#result ='metaWeblog.getRecentPosts', 1,'admin','123456') // Get Recent 10 Post
#result ='wp.getPost', 1,'admin','123456',19) // Get Single Post
#result ='wp.getPage', 1,'admin','123456',1) // Get Single Page
#result ='wp.getPages', 1,'admin','123456',10) // Get Pages
#result ='wp.getPosts', 1,'admin','123456') // Get 10 Posts from wordpress
result ='wp.getPosts', 1,'admin','123456',1000) // Get 10000 Posts from wordpress
#result ='wp.newPost', 1,'admin','123456',post) //For New Creating the Post

puts result // Printresult
puts result.length // Printresult


If you are facing any issue then write to me.

Published by Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published.