wordpress post in android app

The Simplest Way to Get WordPress Post in Android App

From last few days, people asked me- How to Get WordPress Post in Android App? WordPress is a most popular platform to host a blog. It has monthly 409+ million People view more than 19.6 billion pages hosted by WordPress platform. And this count is kept increasing day by day.

So In this blog, I will show you step by step process to get WordPress post in Android App. I will take help of two plugins that make all the content and resources on my WordPress blog accessible. WP REST API is an amazing feature on WordPress. It allows developers to create apps that can easily integrate with WordPress platform.

WordPress REST API for Android

First, you have to install WordPress Rest API v2 on your WordPress blog. Go to the Plugins–> Click ADD NEW –> type keyword WordPress rest. It is the official WP REST API plugin that will be used to fetch data from the blog.

WordPress REST API (Version 2)

Second, You have to install Rest API filter. Using this filter you can short your result like of you want only post id and title, so you can pass filter parameter as id, title.

WordPress REST API – Filter Fields

Fetching All Post of Your Website

  • You can fetch information about all the post on your blog by the following URL. It will return a JSON response that contains all the information about your blog.


for example http://www.blueappsoftware.in/android/wp-json/wp/v2/posts


Fetching Specified Number of Post

  • For fetching a specified number of posts you can use per-page. The below URL will fetch only 3 posts.


    for example http://www.blueappsoftware.in/android/wp-json/wp/v2/posts?per_page=1

Fetching Particular Post

  • You can fetch information about a particular post by using post ID.


for example http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179

Use Filtering Fields

  • Rest API returns all the post information. I will create the problem of the slow start of the android app. As you have seen in above JSON data that there are several fields that we don’t require. So with the help of REST API – Filter Fields plugin you can filter few fields. For example, you want to fetch only post’s id and title then it can be done by using the following URL.


for example http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179?fields=id,title,date

To know more about WordPress Rest API and Filter, Please check here

Watch Video Get WordPress post in Android App

Login & Download source code


50 days android course


1) Install WordPress Plugins
2) Add Gradle Dependency
3) Add RecyclerView and CardView Layout
5) Make Retrofit Request to get JSON
6) Run App on device

Install WordPress Plugins

You have Installed both the WordPress REST API and WordPress REST filter API on you WordPress blog. Please remember to activate it.

Add Dependency on Gradle file

Create a new project on android studio. We have to app Internet Permission on AndroidManifest File. Also, add the dependency for Volley or Retrofit lib. If you don’t know how to use Retrofit to get data from web server please check how to get JSON data using Retrofit

Add Gradle Dependency

Add RecyclerView and CardView Layout

Now add RecyclerView on activity-main.xml and create an adapter for RecyclerView. Here you can see my blog post about RecyclerView. Create another layout name as postdetails.xml for adapter which will display Post Image, post title and post short description inside a cardview.




Make Retrofit Request to get JSON

Create POJO model for Retrofit and a Retrofit API method to send a request to URL. To create POJO model you can use this online tool that auto create POJO model from JSON string. You can use this JSON Editor to see you JSON string in proper structure. Just past your complete JSON string in this editor and click on right arrow. Get all java file and layout by downloading the project for free. I added onclick listener on cardview, so when you will click on any post, I will open new activity with webview. The webview will display your complete post in mobile view, Because my WordPress blog has mobile view campatibility.


Retrofit API call


Run App on device

Now Run this code on the real device. You will see all your blog post title and description is in cardview. You can click on any one of the post to see complete post.

Please leave your comment about video lesson and what problem you are facing on android.

Read MoreGet JSON Data using Retrofit and Send FCM Notification to Device

50 days android course

Posted in andorid, WordPress and tagged , , , .

kamal bunkar

I Am Post Graduation (M.Tech. C.S.E) from VNIT, Nagpur. I Have Published Two Research Paper On International Journal. My Apps on Google Play Store- Sanyukt Parivar(Mp Police ), NOTOtag- Digital Chhindwara, The Tubby-VoiceRecognizer & More.
Contact me at kamal.bunkar@blueappsoftware.in


  1. very nice sir but how we can make a complete site into app like olx amazons big apps with async task json and jsan etc libraries and with this your tutotrial how we can add notifcation that when a new post is inserted a notifcation is shown to user in threads like a olx app

    • there are multiple questions you are asking
      1) for olx, amazons type app, Idea is same they are reading server JSON data using AsyncTask. they created their own API which gives result according to user preference, geography, old purchase history, interest, etc. so you have to create an algorithm for your system.
      2)add a notification, to show notification about new post published on your website, you have to do two things. A) create services in android app that can monitor new total no of post on the website and if there are post count increases then show the notification to user app.
      B) put php server code on your wordpress website, whenever you publish new post it will send notification to all the devices using FCM notification service

  2. sir can u tell how to add naviga drawer further in this tutorials with customizing such as HOME CART SHOPPING CART CHECKOUT PAGE PRODUCTS CATEGORIES PAGE SETTING NOTIFCATIONS woocommerce site into pro app thanks

    • You have to install a plugin to your WordPress website. this way you can get your entire website into a JSON string format. Now create any suitable design on android app and decode JSON string and place appropriate value on your android design.

  3. Hi, I have followed your tutorial and it works for me. But i have a little problem. I want to show my post image in the list where you have set the android icon. Hope you get it. so can you tel me the exact code line to set my post image in it. I have tried this but it didn’t work for me.

    ( (ImageTypeViewHolder) holder).imageView.setImageURI(Uri.parse(object.Image));

    I think i am doing something wrong.

    • hey, you are doing mistake. you need to use glide library to fetch image from URL. Please add glide dependency on project module gradle file then call glide.with(this).Load(object.image).into(( (ImageTypeViewHolder) holder).imageView) Please search on Google about glide.

    • please look at the feature-media tab on retrofit response. It is another url address please hit that url on browser then you will see a json file. that JSON file contains the actual image path of each post. So you need to fire another retrofit/ volley request for the url that you got from each feature-media link. once you get the actual image file path then use glide library to display image.

  4. Thanks for nice tutorial. However I couldn’t figure out how to add image on every post dynamically. I added a Glide dependency and I could get same images for each post with below code.

    .into(((ImageTypeViewHolder) holder).imageView);

    But when I try the code below I don’t get images populated into the posts. Plz could you assist me with this part. Thanks

    .into( ((ImageTypeViewHolder) holder).imageView);

    • Hi, Please have a look on object.image. It is not actual image file path but it is another JSON url. WordPress store post feature image in file manager(having multiple image size combination like small, medium, large etc) and wordpress store only index of these file on feature media tab. Please past you wordpress response on any online json editor (onlinejsoneditor.org) and on each json object you will find “feature media” object. Hit that link on URL so you will get another JSON that contains your actual post feature image path that you can pass on glide. So what you need to do is- on wordpress response for each post get feature media tag and again use retrofit OR volley to get JSON array. Once you get JSON array get the image path from it and pass it to glide. you can do this task inside adapter.

  5. Hello Sir, Thank you for your great tutorial. I’ve come to a bit of understanding about Json Rest Api and Android, but when i try to change the baseURL using another url, i get an error NullPointerException.. the site i used have WP REst API and WP Rest API – Filter Fields Plugin installed. i tried to change to another site URL and install the plugins as well but it’s not working either.. only using your site, the app is working.
    here is the error:

    line 101 is at .get(0), is the problem was with the site?,
    the full Json url is http://r4ndiel.com/wp-json/wp/v2/posts
    so, i changed baseUrl =”http://r4ndiel.com”;
    and the Retrofit interface, changed into:
    is there something wrong with the site or the code?
    Thankyou sir.

      • Thank you for the response. I don’t know if it’s the reason though.. but still nothing change even when i test using another site as i mention before..
        the code is working at least, because there are 3 responses were caught when run before terminate, so the cause probably something else on the sites, i just don’t know what it is.

        I think i’ll start with inspect the site first.. i do suspect the server of the sites i used somehow blocking communications using JSON parsing (maybe?). after all, its all in the same hosting server, or perhaps it’s something to do with the version of WP i used (4.9.4) in the sites, while your site is 4.7.9. i’ll dig some more on the internet.
        Anyway, thank you for the tutorial, this Retrofit is quite easy to understand..
        oh, and if i am not too rude, would you be kind to test the code using my site? i would like to know if it something wrong with my site. Thank you very much.


        • Hey, Look are getting nullpointer exception means some object name is not present on your response. Also you got first three post title that means on 4th post some tag is missing. either feature media or any other tag.. so past your response on jsoneditor and compare 1st post data with 4th post data. definite there is one object name is missing at you are trying on java code inside onsuccessResponse method.

  6. Very nice tutorial, Please let me know how can i replicate the home page responsive design of my blog using android studio.

    • First you need to understand android and web browser are two different things. Web browser uses javascript , boostrap, angular etc to create responsive design. but on android these language doesn’t work. You need to create your website design using java and xml only. so in that can it won’t be look same on android app as it is on web browser. You can create your own design for android app.

Leave a Reply

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