I have this code:

add_filter( 'the_title', function() {
    return "";

Or, respecting the hook's arguments:

function remove_title( $title, $id ) {
    $title = '';
    return $title;

add_filter( 'the_title', 'remove_title', 999, 2);

Which is being placed in a custom made page, my template (used by that page) being:

get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main">
        <header class="entry-header">
            <?php the_title('<h1 class="entry-title">', '</h1>'); ?>
        </header><!-- .entry-header -->
        while ( have_posts() ) :
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            </article><!-- #post-<?php the_ID(); ?> -->
        endwhile; ?>
    </main><!-- #main -->
</div><!-- #primary -->
  • 1
    Where do you place your filter code? Why can't you simply edit this template? Do you want to hide titles on all pages and posts? Shouldn't there be some conditions in your filter? Commented May 23, 2018 at 13:07
  • you can remove '<?php the_title('<h1 class="entry-title">', '</h1>'); ?>' from your code, and if you want to limit it to few pages then you can add a condition or add a custom field for this template so whenever this is selected, you'll get the option to show or hide title at admin area and you can set condition accordingly in the template.
    – Akshat
    Commented May 23, 2018 at 15:04

1 Answer 1


You can try this

function wpb_hidetitle_class($classes) {

    if ( is_single() || is_page() ) : 
        $classes[] = 'hidetitle';
        return $classes;

    return $classes;


add_filter('post_class', 'wpb_hidetitle_class');

CSS code :

.hidetitle .entry-title { 
    display : none;

Source http://www.wpbeginner.com/plugins/how-to-hide-post-and-page-titles-in-wordpress-single-pages/

  • 5
    Ehhh, wpbeginner is really annoying with these dummy tips. This is not a solution - it only makes title invisible - it is still in your HTML, it is still read by browsers and so on... Commented May 23, 2018 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.