Home › Forums › Pro Support › Show a list only if it has content using conditional? › Reply To: Show a list only if it has content using conditional?
April 18, 2019 at 3:52 pm
#8815
Keymaster
Not sure if it will work, but you could try this function:
add_filter( 'post_class', function( $classes ) {
global $post;
if ( ! $post->post_content ) {
$classes[] = 'no-content';
}
return $classes;
} );
Then you can do this:
.wp-show-posts .no-content {
display: none;
}
Let me know 🙂