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.
386
questions
1
vote
1
answer
30
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
19
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
0
answers
9
views
update ACF field when saving post on back office
I am trying to update the value of a custom field (order) inside a POST when it is saved on the back office. If my status is Sold, I want the value of order to be 3. Everything is working smoothly ...
0
votes
1
answer
10
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
67
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
49
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
99
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
35
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
600
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 ...
1
vote
1
answer
761
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
32
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
79
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
250
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
367
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 ...
1
vote
1
answer
148
views
Get category of post inside save_post hook
I don't have much experience with hooks in WordPress so i have found a problem who don't look too difficult, but i can't find the answer.
In my project i have a metabox who will get the content after ...