Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $post_data = array(
- 'post_title' => '',
- 'post_type' => 'post',
- 'post_content' => '',
- 'post_status' => 'draft',
- 'post_author' => 1
- );
- $post_id = wp_insert_post( $post_data );
- add_filter('pre_post_title', 'wpse28021_mask_empty');
- add_filter('pre_post_content', 'wpse28021_mask_empty');
- function wpse28021_mask_empty($value)
- {
- if ( empty($value) ) {
- return ' ';
- }
- return $value;
- }
- add_filter('wp_insert_post_data', 'wpse28021_unmask_empty');
- function wpse28021_unmask_empty($data)
- {
- if ( ' ' == $data['post_title'] ) {
- $data['post_title'] = '';
- }
- if ( ' ' == $data['post_content'] ) {
- $data['post_content'] = '';
- }
- return $data;
- }
- add_filter( 'wp_insert_post_empty_content', '__return_false' );
- $post = wp_insert_post( $post_args );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement