I am new in Android development and I am trying to make an app that will simply display the post categories and posts from a WordPress website. Can any one help me, please.
In one word: yes. WordPress's mobile apps for Android and iPhone allows users to create posts, upload photos, moderate comments and more.
To use the WordPress REST API, simply add /wp-json/wp/v2/posts to the end of your WordPress site URL. This will give you a list of posts (in JSON format). The default number of posts returned is 10, but you can choose to show more or less with the per_page argument — we'll talk about that below.
I think this is better, for using wordpress rest api you need to use Wordpress 4.7 or higher, or install the Rest Api plugin in previous versions. Then you need to configure Permalinks in wordpress, this will make rest api endpoints to work.
For reduce the size and customice the output json you may install the Rest api filter fields plugin see the bellow example:
Fetching Specified Number of Post
For fetching specified number of posts you can use post-per-page filter. The below URL will fetch only 3 posts. http://your-blog-url/wp-json/wp/v2/posts?filter[posts_per_page]=3
Fetching Particular Post
You can fetch any particular post by its id. http://your-blog-url/wp-json/wp/v2/posts/67
Here 67 is the id of the post.
Filtering Fields
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 following URL. http://your-blog-url/wp-json/wp/v2/posts?fields=id,title
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With