WordPress Gutenberg get page template value when post updated?

I need to get the page template name when the post is saved. It fails in save_post hook as $_POST(‘page_template’) is not available. Gutenberg saves post via the REST API and uses WP_REST_Post_Controller->handle_template to save page template data. And like I said it does not make $_POST(‘page_template’) available in save_post. It also looks like WP_REST_Post_Controller->handle_template … Read more

Return code from save_post action?

I’d like to understand what value I should return from a WordPress save_post action function. This example from the save_post documentation both explicitly and implicitly returns without a value: function my_project_updated_send_email( $post_id ) { // If this is just a revision, don’t send the email. if ( wp_is_post_revision( $post_id ) ) return; $post_title = get_the_title( … Read more

How can you receive the most recent permalink or terms of the newly saved post?

When using the Gutenberg Block Editor the normal hooks for saving a post don’t have the same behavior as with the classic editor. pre_post_update save_post wp_insert_post For example, if you hook into the save_post-hook the $permalink and the $categories will not return the new value, but instead the old value. Which is not the behavior … Read more

How to run a function once on every post in database?

I have a simple function that automatically formats the whole post after publishing/updating. It’s hooked on: add_action(‘save_post’, ‘myFunction’); I would like to format every post, that I already have in database. I know I can open every post and click on update to call the “save_post” hook on myFunction on the post, but my post … Read more

Exclude trash from save_post

I have a function which processes custom metabox data on saving my custom post type: add_action(‘save_post_customtypehere’,’myown_save_customtype_fn’); function myown_save_customtype_fn($ID) { … } However, the function also runs when I trash items within this CPT (I guess it’s effectively saving the post to change post_status to trash). Without the metabox being present, my function ends up clearing … Read more