WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Edit PHP remove Page Titles, Keep Post Titles (5 posts)

  1. D C
    Member
    Posted 2 years ago #

    Hey all. I found in my loop.php where my theme (graphene) finds the page and post title and outputs it. I want to hide my page titles, but keep my post titles. I don't understand PHP well, so I'll give the code below and if you could tell me how to change it to keep the Post titles in the h2 tags but print nothing if it's a page, that would be great.

    Thanks

    <h2 class="post-title">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(esc_attr__('Permalink to %s', 'graphene'), the_title_attribute('echo=0')); ?>"><?php if (get_the_title() == '') {_e('(No title)','graphene');} if (is_home() || is_front_page() ) {/*Do nothing*/} else {the_title();} ?></a>
    <?php do_action('graphene_post_title'); ?>
    </h2>
  2. hotplugin
    Member
    Posted 2 years ago #

    just add if(is_page()) next to is_home()

  3. esmi
    Forum Moderator
    Posted 2 years ago #

    <?php if ( !is_page() ):?>
    <h2 class="post-title">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(esc_attr__('Permalink to %s', 'graphene'), the_title_attribute('echo=0')); ?>"><?php if (get_the_title() == '') {_e('(No title)','graphene');} if (is_home() || is_front_page() ) {/*Do nothing*/} else {the_title();} ?></a>
    <?php do_action('graphene_post_title'); ?>
    </h2>
    <?php endif;?>
  4. D C
    Member
    Posted 2 years ago #

    AWESOME!!!! Thanks guys!

  5. gnmeles
    Member
    Posted 2 years ago #

    Hello.
    I was wondering how to achieve the same goal in a twenty ten child theme.create a new page-loop file?

Topic Closed

This topic has been closed to new replies.

About this Topic