Get $_POST & $_REQUEST values before adding/updating post
Get $_POST & $_REQUEST values before adding/updating post
Get $_POST & $_REQUEST values before adding/updating post
I didn’t test this, but it should work: function check_post_attachments($post_id, $post){ if(empty(get_posts(array(‘post_type’ => ‘attachment’, ‘post_parent’ => $post_id)))){ $post[‘post_status’] = ‘draft’; wp_update_post($post); } } add_action(‘save_post’, ‘check_post_attachments’);
The admin_notices hook fires only once per page load, and isn’t fired when a post is quick-edited. You would have to do it browser-side with javascript – that is, listen for when someone edits and saves a post (which is done via AJAX) and use javascript to display a message. A quick glance at the …
It looks to me like save_post doesn’t work the way you currently have your add_action. According to the Codex, you need to run your function on save_post and check the post type in the function. function get_film_data( $post_id ) { if ( get_post_type($post_id) == ‘film’ ) { // If this is just a revision, don’t …
When you choose “Your CPT > Add New”, WP calls get_default_post_to_edit(), which actually creates an “empty” post (with ‘post_status’ => ‘auto-draft’) and then calls wp_insert_post(). This is what is causing your save_datasheet_meta() function to be called before you think it should. Hence, generally you should add some additional sanity checks to the beginning of any …
How to manage saving custom field from Quick edit and Post Save using save_post action hook without colliding each other?
Not an exact answer to your question (hooking into the insert/edit link functionality), but possibly an alternate method that can achieve the same goal (inputting a permalink, outputting a Post ID): https://codex.wordpress.org/Function_Reference/url_to_postid
Did you try removing the IF statements and use save_post hook instead of save_post_listing to see if an IF statement is blocking the wp_set_post_terms? Also try wp_set_object_terms instead of wp_set_post_terms. Furthermore, if you can make sure it has to do with the if(get_post_meta($post_id, ‘wpcf-proprty_online’, true) == ‘y’) statement, then this post_meta has not been updated …
A little late, but I just had this issue where adding a taxonomy term was working, but adding post meta wasn’t. The solution was to set a higher priority. The default priority is 10, so try for instance priority of 100: add_action( ‘save_post_dealer’, ‘save_dealer_long_lat’, 100, 1);
Actions should not return anything, and action hooks are not built to do anything with a returned value. (That is what filters are for.) If you look at the source for that particular hook, you can see that even if you return something nothing happens. Whatever you return isn’t captured. It vanishes from the code. …