Using WordPress REST API, I’m externally getting posts:
https://example.com/wp-json/wp/v2/posts?orderby=date&order=desc&per_page=12
Body results:
[
{
"date": "2022-05-05T12:12:12",
"link": "https://example.com/blog/132/",
"title": {
"rendered": "F: Title"
}
},
{
"date": "2022-04-04T12:12:12",
"link": "https://example.com/blog/434/",
"title": {
"rendered": "E: Title"
}
},
{
"date": "2022-03-03T12:12:12",
"link": "https://example.com/blog/324/",
"title": {
"rendered": "A: Title"
}
},
etc...
]
I’d like to sort title by alphabetical order.
What would be the best solution?
I’m unable to use WP_Query since the posts are being pulled from an external WP API source.
2
Answers
May be something like that :
use this function to sort any array