WordPress build hook not working

Site Name: https://infallible-mclean-a57ed9.netlify.app/

I’m using WordPress as my headless CMS and trying to set up a build hook to rebuild my site when a page or post or custom post type is created or edited. I’ve created a build hook and added a function to my functions.php file:

function deploy_on_publish() {
   wp_remote_post( 'https://api.netlify.com/build_hooks/5f5b9a1dbd35ec6cab7126d7', '' );
}

add_action( 'publish_post', 'deploy_on_publish' );

(following this: Rebuild Netlify on Headless WordPress Post Publish | Blog)

However no build is triggered when I update a post.
Any idea what I’m missing?

Hiya @mikeriley131!

As far a I can tell, that hook has only been accessed once in the past week. The access was an HTTP GET - which won’t work. Needs to be an HTTP POST instead. Let me know if you can get a post sent off and a timestamp + timezone and I’ll be happy to revisit!

You can test from the command line as shown in the codeblock in our docs, just above this anchor:

All sorted. Looks like I needed to add a post_updated hook for updating posts.

1 Like

Thanks for sharing the solution, @mikeriley131.

Thanks for sharing the solution