I’m a beginner for programming and swift. I’m developing an app for my small business. It’s almost finished but i’m completely stucked with blog page. I just want to fetch data from my website which is wordpress, and put my posts in to my tableview. I was searching but couldn’t find a proper answer. Please at least me tell me where to begin with
Thank you
You need to use awesome new API of WordPress called WP REST API, which will give you all data you need in JSON format. Have a look at this url to get started:
http://v2.wp-api.org/
Use this official plugin in your WordPress site:
https://wordpress.org/plugins/rest-api/
Update: You do not need to install above plugin as it has been merged into WordPress core from v4.4 to onwards.
At first, you should define models for parsing the JSON response, for example, as below.
You can easily fetch posts using
Combine
.Full sources you can find here: https://github.com/fuzzzlove/SwiftUIWordpressClient