How do I hide the current page's title?

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 --
        ?php
        while ( have_posts() ) :
            the_post();
            ?
            article id="post-?php the_ID(); ?" ?php post_class(); ?
                ?php
                    the_content();
                ?
            /article!-- #post-?php the_ID(); ? --
        ?php
        endwhile; ?
    /main!-- #main --
/div!-- #primary --
?php
get_footer();

Topic get-the-title page-template filters pages Wordpress

Category Web


You can try this

function wpb_hidetitle_class($classes) {

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

    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/

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.