CPT in Private | WordPress.org

[ad_1]

Hello,

I use your plugin for 2 different CPT. Actually all posts should be stay in private status. I have found a code thats working well for 1 CPT, but i do not find the right way to do it for 2 CPT.

Here is the code i used for the first CPT and its posts to let it private everytime :

function force_type_private($post)
{
    if ($post['post_type'] != 'my_custom_cpt' || $post['post_status'] == 'trash')
        return $post;
    
    $post['post_status'] = 'private';
    return $post;

}
add_filter('wp_insert_post_data', 'force_type_private');

Do you know how to add the second CPT to make it works for the both CPT ?

Thanks a lot in advance

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer