WordPress.org

Ready to get started?Download WordPress

Forums

How to replace/hide page title on front-end (2 posts)

  1. stesvis
    Member
    Posted 3 years ago #

    Hi, i'd like to know if it's possible (i am sure it is and it must be easy but i can't figure it out) to hide the page title only on a certain page. I mean to hide the <h1> or <h2> tag that contains the page title, not <title> of the html page.

    i tried with:

    add_filter("the_title", "hide_title");
    
    function hide_title($title ){
        global $post;
    
        //5 is the id of the page where i want to hide/replace the title
        if ($post->ID == 5) {
            $title = 'Replaced title';
        }
        return $title;
    }

    but it affects all my menu titles (in the nav). They are 'Replaced title' and i have no way to replace the title of a single page.
    Also, i want to keep the original nav titles, just want to change the title inside a page. Any help or hints?
    thanks in advance!

  2. Steffen Jørgensen
    Member
    Posted 3 years ago #

    Use a different pagetemplate for that page.
    Or, use conditional tags, like so:

    <?php if ( !is_page('page-slug') ) {?>
    <?php the_title(); ?>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic