Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/dplugins-code/htdocs/code.dplugins.com/wp-includes/functions.php on line 6131

Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/dplugins-code/htdocs/code.dplugins.com/wp-includes/functions.php on line 6131
Set post types to private by default

Set post types to private by default

Sometimes you have a post type that needs to stay private, like video tutorials for your clients or a quotes for products that should not be seen by the public or indexed by the search engines.

The snippet below will allow you to set all posts from a given post type to private by default.

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');

Remember : Change “my_post_type” to your custom post type.

Click to Copy