I registered a new custom post type and forced it to be private, but now I need to use three custom post type. I registered the second one, but I don't know hot to set the code to force the second one.
Here is the code I used to force the first CPT ('my_post_type1')
function force_type_private($post)
{
if ($post['post_type'] == 'my_post_type1') {
$post['post_status'] = 'private';
}
return $post;
}
add_filter('wp_insert_post_data', 'force_type_private');
How can I force the second ('my_post_type2')?
Thank you very much
I registered a new custom post type and forced it to be private, but now I need to use three custom post type. I registered the second one, but I don't know hot to set the code to force the second one.
Here is the code I used to force the first CPT ('my_post_type1')
function force_type_private($post)
{
if ($post['post_type'] == 'my_post_type1') {
$post['post_status'] = 'private';
}
return $post;
}
add_filter('wp_insert_post_data', 'force_type_private');
How can I force the second ('my_post_type2')?
Thank you very much
Share Improve this question edited Mar 19, 2020 at 23:08 Tom J Nowell♦ 61.1k7 gold badges79 silver badges148 bronze badges asked Mar 19, 2020 at 22:20 Oh-SusiOh-Susi 11 Answer
Reset to default 0You can add multiple compared condition variable in single if condition using logical OR operator.
For more knowledge of Logical condition click
function force_type_private($post)
{
if ($post['post_type'] == 'my_post_type1' || $post['post_type'] == 'my_post_type2') {
$post['post_status'] = 'private';
}
return $post;
}
add_filter('wp_insert_post_data', 'force_type_private ');