Disable a function from executing in post.php
Disable a function from executing in post.php
Disable a function from executing in post.php
Correct, “save_post” saves along with the meta_data which is stored in $_POST, $_GET or $post_data and then it is inserted into the posts table . let me know if that’s helpful.
You have some errors in your code. For example, you unset a not defined variable. Some lines bellow you try to use again a not defined variable….maybe this is what is causing the problems. Can you try this? (Edited, I think is better get_posts than new WP_Query in this case) function wpse_update_postmeta($post_id) { if (defined(‘DOING_AUTOSAVE’) … Read more
From the code you have posted there, it doesn’t look like, at any time, you’re are hooking the function on to save_post outside of your function. function change_pos_auth($post_id){ if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop infinitely remove_action(‘save_post’,’change_pos_auth’); if ( isset($_GET[‘auth_id’]) ) { $args = array(‘ID’=>$post_id,’post_author’=>$_GET[‘auth_id’]); // update … Read more
Saving metadata of related post on save_post
save_post runs too late to do what you are trying to do. That hook fires after the post and related meta data are stored. The category has already been removed at that point, and WordPress keeps no record. You will need to hook into the save process earlier, perhaps pre_post_update: add_action( ‘pre_post_update’, function($post_ID,$data) { var_dump($post_ID,$data); … Read more
Meta data not saved on save_post
You have the add_action that’s supposed to hook your prfx_meta_save function inside the function itself, so it never gets hooked or called. You need to move the add_action outside the function. This will never work: function prfx_meta_save( $post_id ) { add_action( ‘save_post’, ‘prfx_meta_save’ ); } Move it outside the function: function prfx_meta_save( $post_id ) { … Read more
So I found out the problem was in the database. If I deleted the page, then re-created it then it functioned as it should. I couldn’t narrow down what exactly was wrong with the data, but something was. That page did have a lot of revisions, not that it should matter?
Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update