Wordpress - How to publish a post with empty title and empty content?
If the post content, title and excerpt are empty WordPress will prevent the insertion of the post. You can trick WordPress by first filtering the input array so empty values are set to something else, and then later resetting these values back to empty strings. This will bypass the standard check.
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;
}