Skip to content

Instantly share code, notes, and snippets.

@BTMPL
Created December 2, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BTMPL/1b21308ff0ae22fd96cd7794355f8551 to your computer and use it in GitHub Desktop.
Save BTMPL/1b21308ff0ae22fd96cd7794355f8551 to your computer and use it in GitHub Desktop.
<?php
function preventUnnamedPosts($postId) {
$post = get_post($postId);
if(empty($post->post_title)) {
remove_action( 'save_post', 'set_private_categories' );
wp_update_post(array(
'ID' => $postId,
'post_title' => $postId
));
}
}
add_action( 'save_post', 'preventUnnamedPosts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment