Sometimes you need to display the WordPress post content, but you do not want to display the title. This as you do not need it or simply because because you display it elsewhere on your page and do not want to repeat yourself.

You can then of course hide the title with CSS but it then still is in the code. Better to not return it at all.

For that use this code

add_filter( 'the_title', function( $title, $id ) {
    if ( is_single() && in_the_loop() ) {
        $title = '';
    }
    return $title;
},10, 2);

Leave a Reply

Your email address will not be published. Required fields are marked *