I have this working for one post type, but need to do it for three. I tried the "else" statements but I realized I suck at PHP.
function my_comments_open( $open, $post_id ) {
$post = get_post( $post_id );
if ( 'contacts' == $post->post_type )
$open = true;
return $open;
}
I have this working for one post type, but need to do it for three. I tried the "else" statements but I realized I suck at PHP.
function my_comments_open( $open, $post_id ) {
$post = get_post( $post_id );
if ( 'contacts' == $post->post_type )
$open = true;
return $open;
}
function default_comments_on( $data )
{
$myCustomPostType = array("my_custom_post_type_1", "my_custom_post_type_2", "contacts"); /* Custom Post Type Array */
if (in_array($data['post_type'], $myCustomPostType))
{
$data['comment_status'] = 'open';
}
return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_on' );
Add this code in functions.php
in_array()
-in_array( $post->post_type, array('contacts', 'post_type', 'post_type') )
. – Sally CJ Commented Jan 28, 2019 at 4:52function my_comments_open( $open, $post_id ) { $post = get_post( $post_id ); if ( in_array( $post->post_type, array('contacts', 'companies', 'properties') ) $open = true; return $open; }
Does that look correct? – Andrew Commented Jan 28, 2019 at 5:18)
for theif
block. Anyway, check my answer. – Sally CJ Commented Jan 28, 2019 at 5:50