The save-post tag has no wiki summary.
1
vote
2answers
2k 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
4answers
2k 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 ...
2
votes
1answer
780 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);
...
8
votes
3answers
3k views
Passing error/warning messages from a meta box to “admin_notices”
I have a simple meta box that updates the post custom fields (using update_post_meta()).
How can I send a error or warning message to the next page after the user publishes/updates the post and ...
15
votes
6answers
5k views
Add validation and error handling when saving custom fields?
I have a function that defines a custom field on a post type. Say the field is "subhead".
When the post is saved, I want to do some validation on the input, and display an error message on the post ...
9
votes
1answer
2k 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, ...
6
votes
2answers
1k views
Return $post_id when DOING_AUTOSAVE?
I see the following pattern over and over, on this site and on other places:
add_action( 'save_post', 'wpse14169_save_post' );
function wpse14169_save_post( $post_id )
{
if ( defined( ...
1
vote
3answers
1k 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
52 views
Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
I have been beating my brains on this one for days now and my Google-fu is failing me.
I have created a custom meta box with a dropdown menu that lists all of the terms from a custom taxonomy. What I ...
0
votes
1answer
60 views
Minimum Word Count Before A Post Can Be Made Pending Review
I'm looking for a way to check that a post has a minimum word count before allowing it to be sent for review (added to the pending post status).
Below is the code I have:
if ...
0
votes
1answer
236 views
Custom field values get deleted
I created a custom post type:products which also has custom fields: price & shipping. Occasionally, if I leave the edit product window open or refresh it, I lose the values inside price and ...
3
votes
3answers
941 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 ...
4
votes
2answers
1k 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 ...
2
votes
2answers
2k 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!
1
vote
1answer
223 views
How can i create a function to get youtube video time
Tom J Nowell posted this code to help me retrieve the YouTube video time.
Functions
// function to parse the code from the URL
function parse_youtube_video_id_from_url( $video_url ) {
...
1
vote
3answers
2k views
Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types
Post save functions are conflicting with each other when adding them to the save_post action hook.
2 different custom post types with 2 different (one for each post type) custom meta boxes.
I'm ...
0
votes
2answers
316 views
update_post_meta() not working in save_post
I have added some text input fields to metabox in my custom post. Now whenever I put some data in those text fields in admin panel and click 'save', all data vanishes. Here is the code:
<?php
...
0
votes
1answer
314 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
462 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 ...