Jetpack

How to remove the comment form from Carousel View

Sometimes, you may not want your readers to comment on single images. If that’s the case, you can deactivate comments on all attachment pages and in the Carousel view by adding this code snippet to your theme’s functions.php file:

function tweakjp_rm_comments_att( $open, $post_id ) {
    $post = get_post( $post_id );
    if( $post->post_type == 'attachment' ) {
        return false;
    }
    return $open;
}
add_filter( 'comments_open', 'tweakjp_rm_comments_att', 10 , 2 );
This entry was posted in Code snippets, Tips & Tricks and tagged . Bookmark the permalink.
Follow

Get every new post delivered to your Inbox.

Join 63,480 other followers