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.
  • Recent Comments

    Jen H. on Building a Beautiful Photoblog…
    Leo on Building a Beautiful Photoblog…
    David Bennett on Building a Beautiful Photoblog…
    Jen H. on Building a Beautiful Photoblog…
    Soni on Building a Beautiful Photoblog…
  • Archives

  • Install Jetpack to see our line-up of features.

    Install Jetpack Now

    Don’t need all Jetpack’s features? No problem. Only activate what you need!

    Follow

    Get every new post delivered to your Inbox.

    Join 56,446 other followers

    %d bloggers like this: