Using WordPress instead of Parse.com
by bernt & torsten
If you have not heard it yet, Parse announced they’re shutting down their backend as a service. If you’ve built a mobile app with Parse as your backend, you need to migrate to another backend platform or set up your own parse server, as Parse is open-sourcing the parse server.
The good news is that they’re giving developers 12 months to find a new solution, and they’re providing a path to running your own Parse-compatible service. There’s a great migration guide that covers exporting Parse data to MongoDB and running a Parse server built on Node.js and express.
WordPress instead of Parse.com
I have taken a different route, instead of setting up my own parse server, I have taken the route of using WordPress as my backend. My Android app is very simple, it’s a recipe guide for cyclists.
The app is very simple, in that it shows the recipes and you can select recipes by category. My database model requires a recipe table and a category table.
WordPress Plugins to use
To be able to emulate exactly the same data model as on the parse.com service, I needed to take the help of some specific plugins to be able to create the same database model as on the parse.com database.
- Advanced Custom Fields (ACF) – Add Custom Fields
- Custom Post Types UI – Register custom post and category types
- WP REST API V2 – The WordPress Rest API
- WP Custom Category Images – Adding images to category
- WP API V2 Recipe Category Images – Registering category image with WP API V2
What did I do
I configured the Custom Post Types UI creating a new Post Type
When configuring I made sure that I set the REST API to true.
I then created a custom category that is linked with the Custom Post Type.
Make sure your REST API is set to true.
Next, I created my Custom Fields with Advanced Custom Fields (ACF) –
I made sure that the post type for my custom fields is set to recipes.
Adding Recipes
Now after I set up the ACF and CP UI – I can start adding my categories,
I wrote the plugin WP Custom Category Images to add an image for each category. After I set up my categories, I entered my recipes:
When all was done, now I can start using my mobile app to show the content in my mobile app. To do that I needed to enable WP REST API V2 and to register my custom recipe images with the WP REST API V2, I did that by creating a plugin WP API V2 Recipe Category Images which with a few lines of code register the IP. I could have used a plugin like Code Snippets to enter the code, I went with a plugin.
Testing
I use chrome, so for testing, I’m using the chrome addon Advanced REST client – you can also test in the browser.
My Recipe API call – https://<url>/wp-json/wp/v2/recipes/
My Recipe Category API Call – https://<url>/wp-json/wp/v2/recipe_categories/
If you have any questions you can contact me or you can use the comment fields below.
The Illusion of Control
In today's digital age, the illusion of control over our choices is pervasive and...
The Importance of Creativity After 60
As we age, the importance of maintaining cognitive health becomes increasingly clear. For...
Why It’s Important to Exercise When You’re Over 60
Many of us find ourselves in a pickle as the years pile up. Once reliable sidekicks, our...