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
16 views

Custom taxonomy only gets saved in quick edit

I have set up 2 custom taxonomies for my posts: verdicts and sponsors. The problem is that sponsors do not get saved when publishing a post, it can only get saved when I check it in quick edit mode. ...
0
votes
1answer
16 views

woocommerce_product_quick_edit_save hook not fired

I´m trying to add custom fields in the quick edit of woocommerce product. I managed to show fields and populate with jquery but I don´t manage to save data updated. add_action( 'quick_edit_custom_box',...
0
votes
1answer
18 views

Save post action is called twice

I've seen this posted several times with no perfect answer: I have an action hook for save_post on a CPT. I've tried everything I could find but it always gets called twice: Here's my code: function ...
0
votes
0answers
4 views

Redirection to `edit.php` after saving in the backend

I've been battling an issue with one site I manage and haven't been able to determine where redirection is happening. I've seen other posts online about this issue, but the suggestions don't seem to ...
0
votes
2answers
544 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
0answers
8 views

save_post hook not firing on changing post “stickiness” via quick edit

when I hook to save_post like this: function xxx__update_first_sticky($post_id) { if(get_post_type($post_id) === 'post') { xxx__set_first_sticky(); } } add_action('save_post', '...
1
vote
0answers
18 views

wp_schedule_single_event issue with save_post hook in gutenberg

I am using the "save_post" hook to call wp_schedule_single_event. Everything works as expected with the classic editor, however when I try a post in gutenberg there isn't actually a cron ...
0
votes
0answers
9 views

Admin notices are not shown in save post hook with wp5

When saving the post, admin notices is not shown. Simplified code: add_action ( 'admin_notices', 'ltb_show_admin_notices' ); function ltb_show_admin_notices() { // The function is not called at ...
0
votes
1answer
27 views

Changing new post to “pending” on publish - but “Publish failed” - why?

I only want 2 admis to be able to publish events. So I want to change any new event published by any other user to be set to "pending" when the post is "published." Which, I guess, ...
0
votes
1answer
610 views

Custom metabox does not store data

I'm troubled with a custom metabox, could someone give me a helping hand? I've got a custom post type which uses it, but unfortunately it's not storing the data into the database. Any clue? ...
0
votes
0answers
27 views

update_post_meta() doesn't work with save_post action

I am trying to set a _stock_status post meta to 'outofstock' for each product and product variation when it is saved for the first time (not updated). This is the code: function save_product_meta( $...
1
vote
1answer
752 views

Saving zero as meta value

I have a meta_key called "_ordre" and each time I create a new custom post, a new meta_value is set for that meta_key. The thing is, when I set the value of '_ordre' to 0, the meta_value is not saved ...
0
votes
2answers
1k views

Save current post using custom save button

I want to display a custom button in my "Edit post" screen which saves the current post (everything including custom fields) and then runs a function (in my case redirecting to another page). I know ...
0
votes
1answer
2k views

Generate post title and permalink from custom field and post date

I have a custom post type with the following permalink structure /%match_season%/%match_team%/%postname%-%year%-%monthnum%-%day%/ %match_season% and %match_team% are taxonomies. The post type ...
0
votes
1answer
687 views

post_title in save_post action

I use save_post action to save meta field and to check if post title is set. So I check the value returned by empty($post->post_title) but I get true also if I set the title.
1
vote
2answers
2k views

save_post custom post type ? $_POST not working?

i have this code. <?php add_action('add_meta_boxes', 'ct_meta_add'); add_action('save_post','ct_meta_save'); add_action('save_post','ct_parent'); // add meta functions function ct_meta_add() { ...
22
votes
10answers
32k views

Check for update vs new post on save_post action

Is it possible within the save_post action to determine whether it's a new post being created or an existing post being update?
0
votes
2answers
691 views

Why does post-slug not get saved for drafts?

I am trying to get the value of the 'new-post-slug' (the bit that you can edit to customize your slug for a post, but bizarrely doesn't have a 'name' attribute as you'd expect a form field to have ... ...
0
votes
0answers
18 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
1answer
2k views

How to change the post author when the post is published?

I wanted to change the author when a post change from draft to publish. I have $_GET['auth_id'] variable in post edit screen like this ...wp-admin/post.php?post=53&action=edit&auth_id=5. I ...
0
votes
3answers
3k views

Set Primary category using the Yoast SEO plugin

function set_primary_on_publish ($post_id) { global $post; $categories = get_the_terms( $post->ID, 'category' ); // wrapper to hide any errors from top level categories or products ...
0
votes
3answers
45 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 ...
1
vote
3answers
7k views

Is there an easy way to AJAX-ify saving of post?

We have a plugin that allows us to manage custom post types and we'd like to add AJAX functionality in saving, editing, and deleting posts. I couldn't find similar problems in the internet so I'm ...
0
votes
1answer
614 views

How to hook save-post function to use taxonomy term in post-slug?

Hook save-post function to check if taxonomy term is attached or not. If attached then, use taxonomy term in post slug like "taxonomy-term-other-words"...
0
votes
1answer
17 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
14 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
31 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 ...
5
votes
3answers
19k views

Execute action after post is saved with all related post_meta records (data)

I have to execute custom PHP code after new post is saved with all it's meta data. My question is how to achieve that? Tried with save_post action, but it executes before meta records are saved, so I ...
1
vote
0answers
12 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
9 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
153 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
11 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
65 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
173 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 ...
2
votes
2answers
8k views

Remove empty lines (&nbsp;) when author updates their post

Whenever adding an empty line between paragraphs using TinyMCE, the &nbsp; character entity is added. How can I strip the content of all instances of this character whenever an author updates ...
0
votes
0answers
19 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 ) ) { ...
2
votes
1answer
141 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 ...
1
vote
1answer
93 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 ...
3
votes
1answer
6k views

Why is my custom meta box input not saving

I've added the following function to functions.php to add a custom meta box enabling the end user to input a gallery shortcode. I then intend to use this to place a gallery in a specific place on the ...
0
votes
1answer
50 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
1answer
195 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
0answers
65 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
2answers
176 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
1answer
438 views

Editor meta box Showing but not saving

I am trying to create an editor meta box and I have been following tips found in other similar questions without luck in getting the meta box to save and display its content. The meta box shows but ...
0
votes
0answers
331 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
32 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
178 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)...

1
2 3 4 5
7