post_content // instead of get_the_content() to retrieve the post's unparsed shortcode content if ( is_single() && has_shortcode( $post->post_content, 'et_pb_comments' ) ) { $classes[] = 'et_pb_no_comments_section'; } return $classes; } add_filter( 'post_class', 'et_pb_post_class', 10, 3 );