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.

learn more… | top users | synonyms

1
vote
1answer
300 views

using new WP_Query in save_post function alters $post

I'm trying to include a WP_Query in a save_post function for a custom post type. The query is used to check all the other posts for a custom field bh_shortcode to make sure the content of the field is ...
0
votes
1answer
419 views

Using set_post_thumbnail inside save_post action gets overwritten

I've added my own function to save_post as follows: add_action( 'save_post', 'save_recipe' ); function save_recipe( $post_id ) { // ... set $thumb_id from custom code ... ...
1
vote
4answers
439 views

Updating wp_options with an array on save_post results in duplicated entries

I'm not entirely sure this is Wordpress' fault, but I figure I'd ask anyway and see if anyone else has experienced any problems like this before. I'm trying to save an array to a wp_options table ...
0
votes
1answer
1k 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
308 views

Check for page template on save_post hook

I'm reading into the save_post Codex and I find that you need to check the $_REQUEST['post_meta_data'] in the edit window to hook into save_post. I altered the example code: function ...
1
vote
1answer
315 views

Faking the “onSave” event

While a specific use-case, I believe this may benefit others. I am using TurboCSV to mass-import a number of posts into WordPress (which it is doing wonderfully so far). Within that import, I am ...
1
vote
0answers
96 views

Events: Check for other event with same start date and category

I am using The Events Calendar and (correct me if I'm wrong) there is no checking to see if an event has a time conflict with another event that's already been entered. For example, if there is ...
0
votes
2answers
598 views

Save post meta foreach loop

My brain has fallen over. How do I save this post data? Building some key-value pairs in the form. for ($i = 1; $i <= 3; $i++) { $saved = $meta[$i]; //print_r($saved); ...
0
votes
1answer
596 views

How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]

Title: How to create a front facing user sign up, log in and profile pages like FoodGawker.Com Body: Hey everyone! I'll be as direct and detailed as possible. :) I want to be able to sign up ...
2
votes
2answers
507 views

How to verify nonce from Bulk/Quick Edit in save_post?

I need to do something specific in my save_post callback for bulk and/or quick edits, so how do I check the nonce for that? I can only find _wpnonce in the edit.php html source, but can't find an ...
0
votes
0answers
319 views

Stop saving process when metabox is invalid [duplicate]

Possible Duplicate: Prevent post from being published if custom fields not filled Check before publishing, if already exist post with current custom field value I am trying to add some ...
0
votes
1answer
129 views

Secure way to use name_save_pre?

I created a custom post where I need to change the post name regarding to the custom field and taxonomy values. This is how I did it: add_filter('name_save_pre', 'save_name'); function ...
0
votes
1answer
653 views

Auto save title as custom meta field value

I create a custom post type where I removed the "Title", instead I want to use one of my custom meta value to become the title. This is just to make sure the title look good. Know that the post ...
3
votes
4answers
3k views

Force post slug to be auto generated from title on save

I'm running a property site where many properties are sold in apartment blocks. Because of this what the content editors do is create a post/property with all the details and then use a duplicate ...
1
vote
1answer
534 views

pass error to admin_notices on “quick edit”/save_post action

I currently have add_action('admin_notices','my_notice_function'); updating correctly whenever a page is refreshed (it's checking if a certain page has a certain parent) but when using the "Quick ...
0
votes
1answer
69 views

How to extend the page editor?

I'm really a newbie to WordPress. I can edit the page via admin Page menu. There is a form submitted on that page. How can I write my own functions to handle this form submission? In other words, how ...
2
votes
1answer
378 views

How to assign default taxonomy to pages on 'save_post'?

I try to assign custom taxonomies to a page when newly added by the "publish" button. This is the function: function set_default_object_terms( $id, $post ) { if ( 'publish' === $post->post_status ...
3
votes
2answers
413 views

Disable the post save process completely

I need a way to disable the save process completely using an action/filter. Something that works (for e.g.:) in the query, posts_clauses or wp_insert_post/save_post/update_post hooks. So far I only ...
2
votes
3answers
2k views

A Post is saved twice or more during add_action(save_post)

I have added a custom meta box for advanced information for a specific post category, to my create new post page. Now I recognize, that if I save the post, it writes 2 entries in the db with 2 ...
4
votes
2answers
2k views

How to avoid infinite loop in save_post callback

I have been using this site alot for solving my problems, but this time I did not succeed in finding and answer for my problem. I get and infinite loop when using wp_update_post inside a function ...
1
vote
1answer
834 views

Get the post_id of a new post

There are several ways to get the id of a post after it has been saved (auto, etc.), but is there a way to get the post id immediately after you create a new post? I am trying to create a directory ...
0
votes
1answer
899 views

Migrating from metaboxes to wp_editor()

I got a client requirement where the editing facilities available in wordpress had to be available for content that was meant to be displayed on the sidebar of a particular post/page. The content to ...
0
votes
1answer
115 views

Bug: Post needs to be updated twice when adding action for save_post hook

My function does exactly what I want it to do: I'm trying to add/update meta fields in another post type when an "events" post is saved. Except the post needs to be updated twice for the information ...
0
votes
1answer
944 views

Custom Post Type Meta Box Text Input Field Won't Save When Blank

I have some text fields in a custom post type that I fill in at first, but need to delete on a future update of the post. When I delete the text in the field and save the post, the text I deleted ...
2
votes
4answers
4k 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
1answer
737 views

Custom Post Custom Taxonomy Data Not Saving in Edit Screen

I have a custom post type "projects" with a custom taxonomy "project_type." If I select a project type taxonomy within the post editor screen and hit update, the taxonomy isn't updated. Worse yet, it ...
2
votes
1answer
1k views

Check before publishing, if already exist post with current custom field value

I have a custom post type with only 3 custom fields in it. $post_types = get_post_meta($post->ID,'post_types',true); $post_taxonomies = get_post_meta($post->ID,'post_taxonomies',true); ...
3
votes
2answers
4k views

Retrieve 1st image in post and set it as featured image, when post is saved/updated

I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this: // Get URL of first ...
3
votes
0answers
230 views

Have save_post write to database image meta [closed]

Programming rookie back again. I have been studying the add_action('save_post','') but I am having difficulty getting it to work for my needs. The concept is simple - update the database information ...
5
votes
4answers
5k views

Prevent post from being published if custom fields not filled

I have a custom post type Event that contains a starting and ending date/times custom fields (as metaboxes in the post edit screen). I would like to make sure that an Event cannot get published (or ...
0
votes
1answer
506 views

unable to save custom taxonomy terms in a custom-built metabox in wp-admin

I have created two custom taxonomies i.e states and provinces but am unable to save the data in custom build meta boxes in wp-admin: <?php function custom_meta_box() { remove_meta_box( ...
0
votes
1answer
1k views

prevent post submission

I'm using a meta-box for custom post type. I have three problems: WP seems to run the function that I attached to the "save_post" action, every time a new post is opened for editing or reloaded. Is ...
2
votes
1answer
1k 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 ...
1
vote
1answer
79 views

Publish/Update post is changing image links from file url to post url

I've written a filter to wrap images included in posts with figure tags and their captions with figcaption tags. I turned off the visual editor so that it doesn't strip out all the html from the ...
1
vote
1answer
192 views

WordPress as a web app - always auto-save post and meta data

Is is possible to make WordPress auto-save revisiona more often and have the auto-save version always be the most recent version - Like the way google docs works. This would mean the update button is ...
0
votes
1answer
253 views

save_post action doesn't passing post id to my function as argument

I'm adding a box to add / update post screen. add_action( 'save_post', 'psd_upload_kaydet' ); add_action( 'add_meta_boxes', 'psd_upload' ); function psd_upload() { add_meta_box("psd-upload", "Bir ...
1
vote
3answers
307 views

Is it possible to create a post using a metabox?

I am trying to create a post (well, in the end, multiple posts) from a metabox using the 'save_post' hook. I executed the script once, creating 3900 or so new posts before I crawled into posts.php and ...
1
vote
0answers
152 views

Save modified Custom Field content into another Custom Field on article save [closed]

In my articles I allow editors to enter a date in a human readable dd.mm.yyyy format into a custom field. But I also need this date as unix timestamp in the DB. So I wrote a function which takes the ...
1
vote
1answer
566 views

How can I set taxonomy programmatically

Here is my situation. I plan to distribute a theme I am working on and it has a custom post type called Code and it has a custom taxonomy called Languages now I also use a custom metabox with a ...
2
votes
1answer
1k views

save_post + insert_post = infinite loop

I'm trying to automatically create a new post when a post containing a certain custom field is saved - hooking an insert_post function into save_post. This generates an infinite loop. I found some ...
0
votes
1answer
484 views

save radio button selection in post-meta on submit

Right now I'm reading tags from the tag box, and putting them in a form with radio buttons so the user can choose a "main tag" from the tags they just typed in: function write_tags(){ var rawtags ...
5
votes
2answers
3k views

Why won't my metabox data save?

I have a custom post with a lot of meta boxes. I recently tried to add some dynamic metaboxes, using this question: Create more Meta Boxes as needed I managed to get the metaboxes to add nicely, the ...
0
votes
2answers
932 views

Remove image from post_content on save_post

I'm trying to setup a function in functions.php that removes an image from the post_content on save. Everything works up until the time I'm trying to save the content, the page just hangs and I get a ...
2
votes
1answer
876 views

Post Auto Draft Issue

I've made custom post type without title and editor and I use custom taxonomies, custom fields and attachments to form a post. My title is generated from custom taxonomies and custom fields (or "ID #" ...
14
votes
1answer
5k views

Why does save_post action fire when creating a new post?

I'm surprised by the fact that my function that I've tacked onto the save_post action fires when I click the "New Post" link in the Admin Dashboard. Note - this is before I've pressed Save or Update, ...
0
votes
1answer
297 views

Is it possible to detect if a POST action is for a “Save Post” before the save_post action?

What I need to do is inspect the content of the post and title and based on the inspection, redirect to a different page. To do this, I need to know if a "POST" action is for saving a post. How to ...
0
votes
1answer
627 views

Out of Memory - Line 791 of WP-DB.php (mysql_real_escape_string)

Update The end result is that I did not account for Apache memory limits. There were limits placed on the Apache process which caused PHP to be limited regardless of the settings placed on it. ...
2
votes
1answer
829 views

Post Formats in the context of the Database 'Save Post' function

I am trying to pick up an in-depth understanding of how post-formats relate to posts 'in the database' - i.e. what meta information when compiled together constitutes a post format. And yes, I do ...
0
votes
3answers
1k views

troubles with get_post_meta (and saving it)

im having trouble using "add post meta" and "get post meta" : i have a new meta box in my taxonomy : i always have the value "empty meta" inside the input field, even after i enter anything : like ...
6
votes
2answers
4k views

Set custom messages for post update/save

I am trying to make a custom message instead of the default message when i save a post, does anybody know how to do it!