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.

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

Save a loop of single meta box data from selected dropdown lists

The layout of my edit post page I have 193 countries in Afghanistan post and in every single post "passport". I want add post meta data for "Visa Status" for each country of the ...
0
votes
3answers
26 views

Execute php after post save/update

I have created a php script (generate.php) which is querying posts on set criteria and then writing result in custom xml file. I would like to execute the generate.php everytime the post Save/Update ...
0
votes
1answer
16 views

Saving multiple fields (dropdown and text) in custom metabox

I have seen this question asked a bunch but nothing seems to work. I have a simple metabox within a CPT that needs to save two values. It needs to save a dropdown of pages and a url text field. I can ...
0
votes
0answers
13 views

Update Instead of Rewriting Meta Value

I have repeatable fields inside post Post Type and the meta_value is a JSON Object once post saved. I was wondering if there is a way instead of rewriting the whole JSON, to only update the changed ...
0
votes
0answers
13 views

No ACF post meta when using get_post_custom during save_post

When I save/publish a page, I want it to save to all blogs in multisite including its custom fields (using Advance custom fields). The problem is that, when I tried to look at the value of post_meta ...
0
votes
1answer
30 views

Copy permalink to clipboard automatically when publish/update posts?

When a post gets published/updated, a message will be displayed which gives the permalink. Yes we can copy the permalink to clipboard manually, but I want it to be copied automatically, just like it ...
1
vote
0answers
11 views

Keep a post copy when this one is updated - issue

I try to keep a copy of the previous version a custom post when this one is updated. It works, but duplicate the previous version twice. Help appreciated ! DUPLICATE FUNCTION : function duplicate($...
1
vote
0answers
8 views

Programmatically save one/any post

I am using WP All import in order to import listings in a website. Everything works well except displaying all listings in a map. If i edit any listing, and then click Update (without making any ...
0
votes
1answer
143 views

Issue migrating a checkbox-type meta field to the block editor

I'm trying to add Gutenberg support to a plugin that registers a custom post type with a checkbox-type meta field called _meta_restrict, while maintaining back-compatibility with the classic editor at ...
0
votes
0answers
13 views

Not able to show entered value for a text input in a meta box

So I've searched for weeks and I know there are a lot of questions about this topic but I cannot figure out how to show the value that a user inputs into a text field in a custom meta box. I get the ...
0
votes
0answers
10 views

Detect Terms of Current Post on Save

I’m attempting to automatically assign terms from a parent post to automatically generated child pages. I am able to detect all children for the given post and can set a term however when attempting ...
0
votes
2answers
51 views

add_action('the_content', 'my_plugin_content') is null

I am creating in personal plugin where I recover data from a personal table. Con add_action('the_content', 'my_plugin_content'); posso far vedere il contenuto in una pagina. I would like to save the ...
0
votes
0answers
124 views

how to make a calculated fields in ACF

i want to create a field for average rate with other fields All fields are in one field group For Example field1 = 70 field2 = 60 field3 = 80 field4 = 0 field5 = 0 field6_total = 70 im tried with ...
0
votes
0answers
17 views

Issue Saving Posts That Contain Shortcode

We have a custom plugin we developed for events that includes shortcodes to display feeds of events based on categories or tags. For some reason, we've noticed that from time to time when saving posts ...
0
votes
1answer
26 views

Urgent - WordPress keeps creating posts

I was trying to create a WordPress function that altered the post_name. My final function is: function edit_permalink( $post_id ) { if ( 'ratings' === get_post_type( $post_id ) ) { ...
1
vote
1answer
121 views

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 ...
0
votes
1answer
58 views

Meta box html is not updating after saving

I have some meta boxes setup, some are my own, some are initialized in plugins. As the title indicates, these meta boxes are not updating graphically after the post has been submitted. Here's an ...
0
votes
1answer
39 views

How to check for duplicate record before saving a Custom Post Type

I have a custom post type where I need to check for a duplicate record before the record actually gets saved into the database. The requirement is like this: Before saving a record, I need to check ...
0
votes
0answers
44 views

Custom repeater field trying to save custom value

I would like to save each value like this al_ttl_1...al_ttl_2 and how I can display it? Actualy Im using this code to save all value. With the code below I can't see the custom field on backend ( it'...
0
votes
1answer
178 views

frontend submit post jQuery clone row won't save

Why the cloned value won't save in DB ? It's working fine for the first row (not the cloned one) but when I add new value with jQuery(.clone), new added value won't save... jQuery $('#add-embed').on(...
0
votes
2answers
140 views

Custom Meta Box (SELECT2) Not Saving Taxonomy Terms

I have the code, /* * Add a metabox * I hope you're familiar with add_meta_box() function, so, nothing new for you here */ add_action( 'admin_menu', 'rudr_metabox_for_select2_cat' ); function ...
0
votes
0answers
243 views

acf/save_post not getting saved acf values on initial post save

Strange problem here. I'm running exactly same code on local dev and on my server. So I am trying update some of the post object with ACF field data from my post when the user initially saves a post. ...
1
vote
0answers
28 views

Troubles with acf/save_post and WP_Query

I made an accounting system with ACF and CPT, but my client wants to be able to see the balances of each account from the post table in a column and not entering the single of each account. My ...
1
vote
0answers
135 views

Auto-Select Parent Category as Primary

I am using Yoast SEO Premium to handle the selection of Primary Categories. I am currently working with a Listing (listing) custom post type with a hierarchal taxonomy of Listing Category (listing_cat)...
0
votes
0answers
69 views

Save post as a draft if term of taxonomy not selected

I have a custom post type with metabox that contains form and few taxonomies in a side panel. Taxonomies are by default checkboxes, and at least one term of each taxonomy must be selected otherwise ...
0
votes
2answers
72 views

Create post and update in the same flow [closed]

Intro: I'm using a weird plugin called The Events Calendar which vastly operates outside of WP functions. For example, I cannot retrieve custom fields with the WP function. So essentially, my problem ...
1
vote
1answer
38 views

How to change image atributes right before an image to be saved?

I have an installed plugin to import XML content, but it can't change some meta-data of the new image that will be saved. For example, I'd like to intercept the action of saving an image BEFORE its ...
0
votes
1answer
36 views

save button grayed out randomly

Hello wordpress community, we are facing the issue, that the save-button in wordpress is sometimes greyed-out (and stays that way). As far as we observed this, this usually happens on the auto-save. ...
0
votes
0answers
57 views

Updating failed message when a wp_insert_post function is hooked to save_post hook

I was creating a function which creates a new custom post type with the category or taxonomy name if it was created from the post editor. I am simply using the wp_insert_post function with the ...
0
votes
2answers
438 views

Get Category in save_post Hook

in a class I have a function for save_post action. In this function I send an email. All this works except for querying the categories for that post: class _new_notifications { public function ...
0
votes
2answers
26 views

Custom post types saved as basic post

I made a custom post type filters for others post types. The slug is a concatenation like "filters-" . $custom-post-type. And the custom post type appears correctly in the menu : My problem is when ...
0
votes
1answer
29 views

Run a function on all posts

I have a function where I am counting letters in a title and adding that _product_meta_title key, everything is working fine when I am adding a new product but I have 500 products that don't have this ...
0
votes
1answer
114 views

Save_post acf data not updating category of post type

i am trying to assign multiple categories to my Custom Post Type using advanced custom field named 'cat'. But there is nothing saving to my categories. Any help? <?php // Add an action to run on ...
0
votes
0answers
35 views

Force user to write excerpt before saving post? [duplicate]

Is it possible, in functions.php, to force users by default to write an excerpt before they can save a post? And ideally, would it be possible to make this mandatory in only certain post categories?
0
votes
1answer
105 views

save_post() on Menu Save

When the wordpress menu is saved in the backend, functions hooked on to save_post() run. Is there a way to make these run only when singular items are saved, and not when the menu is saved?
0
votes
0answers
68 views

update a custom field with the value of another existing custom field

I am trying to write a function to copy the value of an imported custom field (postalCode) to another custom field (wpcf-adres) when the post is saved or created. But i cannot get it to work, so there ...
0
votes
1answer
26 views

Mutiple Select only POSTing 1 value

In a custom post type edit form, I have a select marked as multiple to allow multiple items to be selected: <select multiple size="6" name="product_ids"> <option value="71">First</...
1
vote
0answers
855 views

ACF (Advanced Custom Fields) not updating post or postmeta values

After changing the name of a ACF field, existing fields for some posts are not updating, but some are. Also, new posts are recorded correctly and can be updated. It's just that some of the old ones ...
1
vote
1answer
79 views

Execute function after a post has been published

I'm using a post crawler on my website that pulls articles from other websites and automatically publishes them on my website. During that process, it checks for any video embed codes; if they exist, ...
0
votes
1answer
288 views

Create post revision on slug change

I'd like to be able to track changes in the slug / post_name field of the post. I've tried using wp_save_post_revision(...); if I detect a slug change, but according to this page wordpress only ...
3
votes
0answers
199 views

What to use: wp_is_post_autosave( $post_id ) or DOING_AUTOSAVE?

I was doing some action on save_post hook, and noticed that there exists wp_is_post_autosave( $post_id ) function. How does it differ from DOING_AUTOSAVE constant? If I want my action not to run ...
1
vote
1answer
143 views

Check if post is added manually or through wp_insert_post()

I might not be thinking this right but here is my situation: I have a custom post type called events. Some of my events are imported from an API and inserted through wp_insert_post() (in a plugin), ...
0
votes
0answers
139 views

Post meta is not accessible within save_post hook

I am using this code to update post meta but it is not working. function run_when_job_published( $post_id, $post, $update){ $post_meta = get_post_meta($post_id); } add_action('save_post_jobs', '...
1
vote
0answers
198 views

Getting gutenberg (WordPress 5) to save TInymce data?

I'm using this function to add a tinymce meta box: add_action( 'add_meta_boxes', function(){ add_meta_box( 'test_tinymce', 'Test TinyMCE', function( $post ){ $field_value = get_post_meta(...
2
votes
0answers
174 views

wp_insert_post_data filter not working correctly after upgrade to Wordpress 5

I have the following code in a project. function vb_post_modified_date_update($data, $postarr) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if (!empty($...
1
vote
0answers
190 views

Support auto-save and revisions for custom fields

I recently read this tutorial about custom fields in WordPress and wrote a simple plug-in to provide a metabox with a set of input fields. I do not use the Meta Box plug-in promoted on the web site. ...
0
votes
3answers
207 views

Wordpress 4.9.8 doesn't save if content has style="

Wordpress 4.9.8 when I save a draft/publish return me an error: Gone The requested resource /wp-admin/post.php is no longer available on this server and there is no forwarding address. Please ...
0
votes
1answer
288 views

On save_post need to wp_insert_post and save partent post id to child post and child post id to parent post

I'working on plugin for custom post types and it's metadata etc. Everything is fine so far but now I need to extend this plugin - I need to create one extra the same custom post on save/edit post when ...
0
votes
1answer
167 views

wp_insert_post inside save_post adds wrong metadata to inserted post

I have code for saving metadata for Student post_type. While saving metadata I also want to add separate posts for each payment in payments array: add_action( 'save_post', 'save_student_meta' ); ...
1
vote
1answer
76 views

Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta

I believe there are multiple ways to use nonce. Recently I've used wp_nonce_field('any_nonce_value'); which creates a <input type="hidden" id="_wpnonce" name="_wpnonce" value="111bc61eba"> ...

1
2 3 4 5
7