We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

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?

#8815
Tom
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 🙂