Customizing WordPress theme (Twenty Thirteen). How to remove one title from the header without removing them all

I am working on a WordPress theme and I want to edit the page where the title headers are located. (To be more specific, I am working on the’twenty thirteen’ theme). Now, I only want to remove the title in the home page which says ‘Home’. However, I cannot do that because that would remove all the titles in all the pages. So I have to make an if/else statement. The problem is nothing is working with me – pasted below is the code:

<header class="entry-header">
    <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
    <div class="entry-thumbnail">
        <?php the_post_thumbnail(); ?>
    </div>
    <?php endif; ?>

    <h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->

Related posts

2 comments

  1. As I found out function the_title() give you the page title. simply use this and put your html code between if block to customize it.

    <?PHP if(the_title() === 'home' /* is_home() */): ?>
    ... <!-- your html -->
    <?PHP endif; ?>
    
  2. You can achieve that by using the is_home() method.
    Here is the reference to the method.

    <header class="entry-header">
    <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
    <div class="entry-thumbnail">
        <?php the_post_thumbnail(); ?>
    </div>
    <?php endif;if(!is_home()):?>
    <h1 class="entry-title"><?php the_title(); ?></h1></header><!-- .entry-header --><?php endif ?>
    

Comments are closed.