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
1answer
15 views

Custom Post Meta from custom metaboxes is randomly being deleted

For a while now I've been applying and updating some custom metaboxes that my company re-uses on different sites. (Not the same metaboxes, but the same methodology.) Essentially it allows for the '...
0
votes
0answers
17 views

Save / Update meta data as multidimensional array

I need some help with saving my meta data from a post. On the editpage I have the following input fields <input type="text" name="data[color][]" value="red"/> <...
0
votes
0answers
9 views

Select input in metabox not updated

I try to figure it out why my select input did not update the value. I have placed the select input in the header of a metabox, the same what Woocommerce did with the producttype selector. ...
0
votes
1answer
22 views

Adding term to a custom taxonomy based on term from product category

spent over four hours on this and still hitting a wall, hope StackExchange knows better. :/ Basically, I have some Woo products and whenever a new product is added, its name should be saved as a term ...
0
votes
1answer
31 views

Exclude URL's from sanitize_html_classes

I've searched through the similar questions but found nothing. I've coded a meta box for adding custom URL's which get added to buttons on single posts but when the URL is added to the meta box field ...
0
votes
1answer
39 views

How check if a post is saved from backend or frontend?

I created a custom post type called wasb_contact which can be inserted and edited both from the backend and from the frontend (through a form I created). The CPT has some custom meta fields which are ...
0
votes
0answers
23 views

Bookmarking custom template pages which all have the same page ID

I have a custom page I created in WP which displays different real estate listings. Since it is a custom page the page ID is always the same. For example both of these URLs display different ...
2
votes
2answers
38 views

Get updated post meta on save_post action?

I'm trying to save post id and keyword (Yoast Focus Keyword) to a custom table when post is created or updated via save_post action. It saves everything fine on Publish (first-time) but when I update ...
0
votes
1answer
24 views

Custom meta box values are not getting saved for my custom post type

I have created one dummy post type to check the values, if it's getting saved or not. However it's saving values for 'text input and text area' but remaining values (checkbox, select, images) are not ...
1
vote
0answers
55 views

"The link you followed has expired" & "Error while saving" messages when adding new post

I'm currently unable to publish new posts on my wordpress site. Whenever I try, I get a "The link you followed has expired" error after clicking the "publish" button. Also, as I'm ...
0
votes
1answer
47 views

Wordpress sent multiple requests on update

I have a problem with hooks being fired multiple times when I press update on a post (page in this example) I tried everything here: Unable to prevent function using save_post firing twice But since ...
0
votes
0answers
41 views

How to create a user ability to save pages with full url?

Problem: I have a real estate website with dynamic pages. For example when you click on a property it links to http://example.com/property/?id=23432434. I want to give users the ability to save a ...
0
votes
0answers
89 views

Save a custom field in a custom table when saving a draft

I created a custom metabox with a custom field inside. I attach code. add_action( 'admin_menu', 'mtb_add_metabox' ); function mtb_add_metabox() { add_meta_box( 'mtb_metabox', '...
2
votes
0answers
434 views

Correct processing of `$_POST`, following WordPress Coding Standards

Background I'm building a project that according to the specifications need to follow the WordPress Coding Standards. I am using phpcs to scan my code. If I try to pass $_POST-data into a function ...
0
votes
0answers
21 views

Deleting CPT post by code (ie in a plugin) redirects to the main post type

Suppose a CPT In functions.php or in a plugin, hook on 'save_post' to perform some calculations upon hitting the Publish button in WP-Admin... Inside the hook's code include some conditional logic ...
0
votes
1answer
100 views

Run function after a post has finished saving - callback function perhaps?

Upon saving a new post (of a certain post type), a given operation has to run. The problem is that the operation is calling an external (slow) API, which means that the (not logget in) end-user might ...
0
votes
0answers
28 views

Add Tag to post after publishing

I want to add a specific tag to posts being published, I tried the following code and searched for answers here but it doesn't work. Does anyone have an idea why? function tag_to_published_post( $...
0
votes
0answers
58 views

AJAX Saving a meta post does not work in Gutenberg using my save post button

I've created a meta box with posts and would like to save it by clicking the submit button. Saving with Ajax works well in the classic editor and stops working as soon as it moves to Gutenberg. Would ...
1
vote
0answers
55 views

Custom Taxonomy terms aren't getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?

I am using Woocommerce, Elementor, ACF Custom Fields and CPT for Custom Post types. I have a custom taxonomy called 'biographies' which has some associated custom fields (first name, last name, birth ...
0
votes
2answers
162 views

Wordpress publish_post hook not getting featured image and meta on first publish, but works on updating title

I've been struggling to find a solution for this and I don't know if it's the Gutenberg editor or if it's the hook publish_post. Hook: function api_method($post_id) { // If this is just a revision,...
0
votes
0answers
61 views

Is there a way to get rendered html content of a WP post after updating?

I tried adding a filter at the content etc but that one just gives access to content stored in wp_posts. I am interested in getting the rendered html with meta tags etc for a post, after it is updated....
0
votes
2answers
34 views

When the new post which has no image published, save the specific image as the featured image ( by category )

As the title, I would like to save the post with the specific image as the featured image, when it is new published. Also I would like to save different images which is filtered by categories. I have ...
0
votes
0answers
86 views

Post and Pages section inside WordPress admin are completely blank

Meta Tags - Undefined array due to meta tags! I have created my own custom post meta tags but all works fine until I test my WordPress theme on the new WordPress Installation. What I came through ...
0
votes
1answer
23 views

How to detect that the save_post hook is calling the callback associated to the current edit post page only

I am using the save_post hook to handle updates in a post that are done via the admin edit post page. But since I have more than ten custom post types, the save_post associated to each one of them is ...
0
votes
1answer
96 views

Change post author without using wp_update_post()

The standard or more obvious way to change a post author in WP is to use the wp_update_post() function, as shown in this question. But I am having an issue, described as follows: // Inside the ...
1
vote
0answers
38 views

Use the backbone.js client to save custom post type meta

So I have this small piece of code that renders an array of IDs: const selected = this.$data.list.selected; function get_ids(input, field) { const output = []; for (let i=0; i < input....
0
votes
1answer
192 views

Save values from a pre_post_update

I have looked around for an answer here but I didn't find exactly what I'm looking for so I give this a try: I'm creating a plugin. I've created a custom post type I've created a metabox associated ...
1
vote
0answers
14 views

How can I create a new user account while creating a new post, and then set that new user as the author of that new post?

I have a custom meta box with some user information fields, and when the post is published, the new user account is created, along with the new post. However, the new post's author is set as the ...
0
votes
0answers
42 views

Taxonomy Child Not Updating Unless I Click Update Twice

I am using code from this answer to create a new child taxonomy term, however for some reason the change only takes effect if I click update post twice. Clicking Update Post once doesn't save the ...
0
votes
1answer
92 views

Use value from ACF to populate other fields

I am struggling with this problem. I have a group pf ACF fields and a XML file with the corresponding values. What I want is the user to be able to fill one field (with an id) and on the Publish post, ...
0
votes
2answers
37 views

Remove a category from a post when saving a new post

I'm having problems with my code. I'm trying to remove a category from a post that's using that category and then adding that same category when saving a post. For example, if I have a post that's ...
0
votes
1answer
179 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
1answer
76 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
0answers
53 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. ...
1
vote
0answers
72 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
1answer
37 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
3answers
494 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
28 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
1answer
59 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
15 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
38 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
221 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
2answers
187 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
24 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
28 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
289 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
2answers
410 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
229 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
350 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
435 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 ...

1
2 3 4 5
8