I need feedback all the time turned off for media attachments. I wrote the next codes to perform this. However this code is just not working.
I’ve additionally reviewed many related subjects:
Useful resource-1, Useful resource-2, Useful resource-3…
Additionally sure there’s a plugin for that: Plugin Hyperlink
However I do not wish to set up a plugin for it. I might recognize it if somebody might inform me the place I went fallacious.
// Not Working
add_filter( 'wp_insert_post_data', 'turn_off_comments_for_media_items' );
perform always_turn_off_comments_for_media_items( $information ){
if( $information['post_type'] == 'attachment' )
$information['comment_status'] = 'closed';
return $information;
}
// Not Working
add_filter('comments_open', 'turn_off_comments_for_media_items_2', 10 , 2 );
perform turn_off_comments_for_media_items_2( $open, $post_id ) {
$submit = get_post( $post_id );
if( $post->post_type == 'attachment' ){
return false;
}
return $open;
}