Questions tagged [save-post]
save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited.
387 questions
0 votes
0 answers
30 views
Why does my custom slug only show in Gutenberg editor after page refresh?
I'm using an acf field to create a custom slug for a post type. Everything works and saves correct in the database. Only the shown value of the link field in the backend is not updated on publish. I ...
0 votes
0 answers
49 views
Block validation failed for React Component block that rehydrates after taking effect
I have this specific block than when I insert in the Editor, gives me this error: and the error states: Content generated by save function: <div class="data-props" style="display:...
1 vote
1 answer
352 views
Why would I get a "Trying to access array offset on value of type bool" warning when using "metadata_exists()" in save_post?
When saving a post that is a custom post type (in the example, 'my_cpt'), I'm trying to check if a specific piece of metadata exists for that post. I'm using this exact same code on another site (...
0 votes
1 answer
48 views
Show admin notice if metabox field is empty during save post
Who can help me a little. I try to get an admin error notice if a metabox field is empty during save post. Wordpress refresh the page after saving so the hook admin_notices does not work. Here is my ...
0 votes
1 answer
40 views
Custom fields empty after refreshing page
I have added some custom fields to the Gutenberg editor, the purpose is getting these custom fields loaded in the custom-post-type. Thats is all working, I was able to get the custom-fields in the ...
1 vote
2 answers
903 views
Generate Post Title From ACF Fields on Custom Post Type
I have tried a few versions of the code to get this working and seem to come up with a couple of errors either way. I am using ACF for the fields and adding the below code to the themes functions.php ...
0 votes
2 answers
123 views
Check if new post or update before save_post action
I want to use save_post on an update for an existing post and also for a new post, but I want 2 different "priority" on the save_post action. So, I can't check if it's an update into ...
1 vote
2 answers
254 views
How to run this plugin every time a post is saved?
So far this is what I have... I'm new to developing plugins so I'm not sure how to make a plugin run code on a post save. I know that this would likely work if it was added to the post.php page but I ...
0 votes
1 answer
91 views
Webhooks - Differ between new/existing updates
I'm currently trying to work with webhooks without using any plugins, and I'd like to avoid them if possible. The webhook should be triggered when a change is made to the Custom Post Type "event.&...
0 votes
1 answer
1k views
How to automatically update ACF field value every year?
I'm using ACF in my custom post type and I have 2 numeric fields: one for Birth year and another for Age. I want to update the age field automatically based on the birth year field value. I found out ...
2 votes
1 answer
1k views
ERR_CONNECTION_RESET on post save or add media
About a year ago the site was moved to another host (same domain name). Every time I attempt to save a post, page or upload media, I'm immediately sent a connection reset error (This webpage is not ...
1 vote
0 answers
51 views
Resaving posts to update static blocks
I changed markup in my custom static block and now I have to resave custom posts where I use them in order to update what is shown in the front. I tried to automatise procedure by using wp cli command ...
0 votes
1 answer
117 views
How do I set a custom post type Category after import using wp_set_post_terms
I'm importing Events from a Salesforce Event Manager into WordPress, specifically into the The Events Calendar. The Events Calendar creates a CPT called Events. It also has its own Categories, which ...
0 votes
1 answer
313 views
Set post status to draft after validating post meta values in save_post hook
I have some custom meta values to a custom post type ('event'). The custom post type is displayed in the admin and the custom meta fields are appearing fine. I am using save_post_{$post->post_type} ...
0 votes
1 answer
470 views
Save_Post change Custom Post Type Post title to post id number
I have a Custom Post Type with the slug of "sightings". I do not need a post title, so I have removed the functionality - but now the posts are being saved as (no-title). I read about the ...