How to save post_status using action save_post?
How to save post_status using action save_post?
How to save post_status using action save_post?
problem when uploading file by metaboxes
You can use wp_insert_term_data: add_filter( ‘wp_insert_term_data’, function ( $data, $taxonomy, $args ) { $data[‘slug’] = ‘c8etv35n-c8etv35n-c8etv35n-c8etv35n’; // generate slug however you wish. return $data; }); I found it in wp_insert_term function here. But you should really implement ACL and not rely on random slugs to hide the content.
So, I had to explicitly define the key value pairs to get it to work when untrashing. Not sure why it worked everywhere else though as just an array of ids. added: $thisupdate = array ( ‘fields’ => $pages, ‘post_status’ => ‘publish’ ); wp_update_post( $thisupdate );
On a whim I tried this: stop checking for a custom post object and just use save_post. I’m able to get the data I need from save_post without using save_post_type. That is, I can run this: add_action( ‘save_post’, array( $this, ‘post_actions’ ), 11, 2 ); And instead of only running that when the post type … Read more
WordPress dosn’t save page/post updates
The reason for that is the save_post loop. When you call wp_insert_post, it triggers save_post and thus inserts the student meta. what you can do is, to check if the post type is correct while inserting the meta. like: add_action( ‘save_post’, ‘save_student_meta’, 10, 2 ); function save_student_meta( $post_id, $post ) { if ( ‘student’ !== … Read more
Here’s an updated version of your code: add_action(‘save_post’, array($this, ‘save_post_type_example_meta_boxes’)); function save_post_type_example_meta_boxes($post_id) ………. if (…) { $new_custom_post = array( ‘post_title’ => $title, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_type’ => ‘custom_post_type’, ‘meta_input’ => array( ‘meta_1’ => ‘X’, ‘parent_post_id’ => $post_id, ), ); // Prevent this action from running twice. remove_action( ‘save_post’, [ … Read more
Post meta is not accessible within save_post hook
update a custom field with the value of another existing custom field