Force custom post type to be private

Adding this PHP snippet to the functions.php of your wordpress theme will force your custom post type to be private by default. Do not forget to change my_post_type to the name of your custom post type. This is a slight change from the source snippet and does not include a password since this is private and not password protected.

 

 

function force_type_private($post)
{
if ($post['post_type'] == 'my_post_type')
$post['post_status'] = 'private';
return $post;
}
add_filter('wp_insert_post_data', 'force_type_private');

Be Sociable, Share!

Leave a comment