In this tutorial, we go over how to scrape a remote data source (API) and store that data in a Custom Post Type that has a set of Advanced Custom Fields. This is a real-world project that I used to create a timed-scrape for a side project.

Sign up for the newsletter to notified about the free 2020 WordPress Development Course: https://wpcasts.tv

Get WordPress Hosting:
http://wpcasts.tv/go/kinsta

**Don’t forget to subscribe!**

***Make sure to visit the live project: https://brewla.la/ ***

Correction at 33:51 – “weekly” is a custom interval. You have to create that on your own with something like this: https://developer.wordpress.org/plugins/cron/understanding-wp-cron-scheduling/

** FULL CODE REPOSITORY **
https://github.com/alexander-young/brewlala

**SOCIAL**
Twitter: https://twitter.com/_WPCasts_tv_
Instagram: https://www.instagram.com/the_alex_young/

#WordPress #API #RealWorldProject

source

32 Comments

  1. Hi , i have a question about this part 'if( $brewery->updated_at >= $exisiting_brewerey_timestamp )' , why you checking '>=' , then condition will always be true , not only if job 'updated on' was bigger , also you are checking if post exists by 'slug' , if in the api title is changed , that will be considered as a new post , which will add post twice

  2. Correct me if I'm wrong, but when you put >= on line 73 (31:40), the = takes away the whole purpose of the function, which would be to update only the newest ones (>). Those with the same timestamp (=) shouldn't be updated.

    The tutorial is excellent, and it helped me a lot. Thanks. 👍

  3. Thank you for this very useful tutorial. However in my case I was not able to write the fields created by ACF. I was able to see the post titles in the custom post type I created however not necessarily the contents of the ACF fields I created. What in your opinion is the problem? Thank you…

  4. good tutorial but storing a db in wordpress is archaic and dumb because you do not get real time data, it relies on a constant stream of data from the host to the wordpress data. this is really piss poor way of doing things. what is the point of having an API if you cant query the customers database which is never going to be in the wordpress eco system. use a real website and code and get the job done properly – hate me if you want, anyone who is a real programmer will not disagree with that.

  5. Wow. This tutorial is really good and you made it very easy to follow without skipping important parts and giving a clear path to follow. I'm glad I found the video!

  6. Hi, first of all great video! Learned a lot from it. I have one question, What if a brewery is deleted from the API? How will you find the obsolete brewary in your WordPress database and delete it there as well? What checks can we run to achieve this?

  7. Any idea as to why there would be two entries created instead of just one? They both have the same permalink but show up twice in the Breweries CPT.

  8. I sent you an email and haven't heard back. Is there a better way of getting hold of you? Looking to hire for something very similar to this.

Leave A Reply

Please enter your comment!
Please enter your name here