Ali Akkawi
Ali Akkawi

Reputation: 313

WordPress posts keep changing order Android app

I am working on an Android application for my Wordpress site, I've added the Rest API plugins in order to be able to get the data in JSON form.

I am using the following URL to get posts

http://mywordpress.com/wp-json/wp/v2/posts/?categories=1&per_page=100

I am using &per_page=100 because it seems that by default it loads only 10 posts. My problem is that every time I load posts in my Android app, the posts are displayed in a random order, I am using SwipeRefreshLayout so that I can refresh the posts, but each time I do the refresh the posts are displayed in random ordered, is there a way I can order my posts by date desc?

Upvotes: 0

Views: 62

Answers (1)

Jim Bergman
Jim Bergman

Reputation: 5237

JSON data can never be relied upon to be in a certain order. Refer to JSON order mixed up

Sort the data to get a certain order.

Upvotes: 0

Related Questions