function jpcarousel_auto_close_comments( $open, $post_id ) {
$post = get_post( $post_id );
$days_old = (int) get_option( 'close_comments_days_old' );
if ( ! $days_old )
return $open;
if( $post->post_type == 'attachment' && time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'jpcarousel_auto_close_comments', 10 , 2 );
Automatically close comments in the Carousel view
You can use the following code to automatically close comments in the Carousel view, based on the number of days you’ve defined in Settings > Discussion:
Entdecke die Vorteile von Jetpack
Erfahre, wie Jetpack deine WordPress-Website schützen, beschleunigen und beim Wachstum unterstützen kann.
Hast du eine Frage?
Kommentare sind für diesen Artikel geschlossen, aber wir helfen dir trotzdem gerne weiter! Besuche das Support-Forum – wir beantworten dort gerne deine Fragen.


