WordPress REST API – Write to JSON File?

I’ve been messing around with the WordPress REST API, and created my custom endpoint, and getting the exact data I want. Basically I created an endpoint to receive all my post/pages/acf – Instead of calling the API on each page load, I just wanted to call the API once during my preloader.

However, when I call the API, all the logic runs, which then causes a loading time of 1 to 2 seconds. Is there a possibility that whenever I make an update on WordPress, it will call my endpoint, and write a JSON file on the server, so data.json? This way, when I load my site, it can call that data.json, with absolutely no delay at all.

I’m not sure if this is possible but wanted to try asking here.

Read more here: WordPress REST API – Write to JSON File?

Leave a Reply

Your email address will not be published. Required fields are marked *