Why would I get a “Trying to access array offset on value of type bool” warning when using “metadata_exists()” in save_post?

Thanks to mmm’s comment above, it was pointed out that even for CPTs the first parameter’s value needs to be “post”, as clearly stated in the documentation at https://developer.wordpress.org/reference/functions/metadata_exists/. Somewhere along the way I confused myself into thinking that the first parameter’s value needed to be the CPT handle for a custom post type (CPT), … Read more

Check if new post or update before save_post action

You can achieve this by using the wp_insert_post hook, which is called before the post is saved or updated. Inside this hook, you can check if the post ID exists to determine if it’s an update or a new post. Here’s how you can do it: add_action(‘wp_insert_post’, function ($post_ID, $post, $update) { if (!$update) { … Read more

My custom title gets duplicated at every save or post update

First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample. The save_post action hook runs everytime a post (or page) is created or updated. Hence your callback runs everytime. Let me offer two solutions: 1 Use the wp_insert_post action instead … Read more

Connection Reset on post/page save

If you are running mod_security or anything like that would be first thing to check. Security modules are server are known to react badly to WP’s POST requests. That is consistent with circumstances you describe (post saves, Ajax).