WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] need to hide the home page title only (6 posts)

  1. gabesands
    Member
    Posted 6 years ago #

    Hi,

    I wish to remove the page title in the home page only and keep it in every other page. Basically, the opposite of the code bellow.

    <?php if (!is_page('home')) { ?><h2><?php the_title(); ?></h2><?php } ?>

    I've tried searching for it and tried to code it, but anything I tried didn't work.

    Thanks!

  2. gabesands
    Member
    Posted 6 years ago #

    I figured it out!

    <?php if ( is_front_page() ) { ?><?php } else { ?><h2><?php the_title(); ?></h2><?php } ?>

    English:
    If it's the frontpage then show nothing, or else show the title

  3. tracyselena
    Member
    Posted 6 years ago #

    and this change is made where? in which file?

  4. gabesands
    Member
    Posted 6 years ago #

    you change it in the index.php file or page.php file (if you have a main page), just make sure that you edit the correct line (the one within the body).

    Search for
    <?php the_title(); ?>
    and add
    <?php if ( is_front_page() ) { ?><?php } else { ?>
    in front and
    <?php } ?>
    behind it.

    The optional H2 tag is used to make it a secondary heading.

  5. kjagen
    Member
    Posted 5 years ago #

    How can i do that here.

    This is the page code

    <?php if (have_posts()) : the_post(); update_post_caches($posts); ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><?php the_title(); ?></h2>

    <div class="content">
    <?php the_content(); ?>
    <div class="fixed"></div>
    </div>
    </div>

    <?php else : ?>
    <div class="errorbox">
    <?php _e('Sorry, no posts matched your criteria.', 'inove'); ?>
    </div>
    <?php endif; ?>

    <?php include('comments.php'); ?>

  6. kjagen
    Member
    Posted 5 years ago #

    Like this for example; resolved

    <?php if ( is_page(GUITAR) ) { ?><?php } else { ?>

    <h2><?php the_title(); ?></h2>

    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic