How to get data from WordPress.



WordPress is #1 blogging platform. It’s easy to use, powerful, very extensible, there are literary millions of themes, plugins and widgets.

According to some sources, It powers around 32% of the web sites. That’s huge!


I tried to pull some data from one WordPress to another WordPress installation. As I normally do, first I checked if some fancy plugin or widget exist in enormous WordPress plugin repository. After a while, I did not find (did not conform all my needs) any nice and easy solution.

So, I dig deeper. After a bit of investigation, I found out that WP 4.7 introduced very useful feature: REST API Content Endpoint. Problem solved!

I found REST API reference here:


In general, there are two ways to integrate RESTFUL services into web pages:

  • Client side by some JavaScript framework, e.g. React, Vue.js, or just plain JavaScript. Major issue with this approach is cross-domain calls, which can be difficult to handle. One solution to this problem is to proxy data over own backend.
  • Server side integration. In this approach server side pulls the data, generates response and send it to web client. In the case of WordPress server side PHP executing engine handles this. Because I wanted also to include some kind of caching mechanism this was the natural solution to try.

WordPress RestAPI Content Endpoint.

My idea was to display latest blog posts in destination WP installation. After quickly reading the specifications I could easily get data form source WordPress installation by:

response is:

So, from source WordPress I got all I needed. I had adta in JSON form. Ideal form for integrating into systems.

WordPress backend code – PHP example.

I used PHP Everywhere plugin for WordPress to enable injecting PHP code into pages or posts. After I was able to put some PHP logic in my posts/pages, I insert code similar to this (Note, code is not production ready, but for the first review is just ok).

I did similar for Recent posts sidebar and Category listing and integrated in WordPress page and make it as start page.


So, my problem was solved, just quick look at source and destination web page.

Destination WordPress portal.


WordPress version 4.7+ exposes data over RestApi service. This is very useful feature because it enables WordPress data to be exposed and used by external systems via Restful services.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.