Remove Page & Post Entry Titles Conditionally in Genesis

If you’re looking for a solution to remove post and pages titles, this tutorial is for you.

You can hide titles using CSS code on a per post and page basis using custom classes or the post i.d for a specific page.

But what if you want to remove your titles on all posts or pages?

Using PHP code in a custom function with conditional tags enables you to be more specific.

The code for removing titles from themes running the old Loop hooks is different to the code for themes running HTML 5.

Remove entry titles from all single posts

add_action( 'loop_start', 'remove_titles_all_single_posts' );
function remove_titles_all_single_posts() {
    if ( is_singular('post') ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page titles from all single pages

add_action( 'get_header', 'remove_titles_all_single_pages' );
function remove_titles_all_single_pages() {
    if ( is_singular('page') ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page titles from specific pages

add_action( 'get_header', 'remove_titles_from_pages' );
function remove_titles_from_pages() {
    if ( is_page(array('contact', 'about') ) ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page titles site wide

remove_action('genesis_entry_header', 'genesis_do_post_title');

Remove post titles from specific single posts

add_action( 'get_header', 'remove_titles_single_posts' );
function remove_titles_single_posts() {
    if ( is_single(array('contact', 'about') ) ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove post titles from home page

Assumes you’re using the default WordPress Reading Settings so your front page is your posts page.

add_action( 'get_header', 'remove_titles_home_page' );
function remove_titles_home_page() {
    if ( is_home() ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove Titles From Themes Using Old XHTML Loop Hooks

Here’s a list of code snippets which you can use or modify based on your own needs.

Remove page titles site wide

remove_action('genesis_post_title', 'genesis_do_post_title');

Remove page title for one single page

add_action( 'get_header', 'remove_page_title' );
function remove_page_title() {
    if ( is_page( '3' ) ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page titles using post i.d’s

add_action('get_header', 'remove_specific_page_titles');
function remove_specific_page_titles() {
    $pages = array( '222','333' );
    if ( is_page($pages) ) {
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page/post/attachment titles

add_action( 'get_header', 'remove_page_titles' );
function remove_page_titles() {
if ( is_singular() )
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}

Remove page titles from all single posts & pages

add_action( 'get_header', 'remove_titles_pages_posts' );
function remove_titles_pages_posts() {
    if ( is_singular() ){
        remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page titles from specific posts

add_action('get_header', 'remove_specific_post_titles');
function remove_specific_post_titles() {
    $pages = array( '5','10' );
    if ( is_single( $pages ) ) {
       remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
}

Remove page title on specific page

add_action('get_header', 'remove_page_title_specific_page');
function remove_page_title_specific_page() {
if (is_page('007')) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
}

Remove post titles on home page only

add_action('get_header', 'remove_post_titles_home_page');
function remove_post_titles_home_page() {
if (is_home()) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
}

Remove titles on single posts but not single pages

add_action('get_header', 'remove_post_titles');
function remove_post_titles() {
if ( !is_page()  || is_single() ) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}

These working examples should give you a pretty good idea of how to remove post and page titles in Genesis using PHP code. All you need to do is make sure you use the correct conditional tag.

Related Code Snippets


Comments

18 responses to “Remove Page & Post Entry Titles Conditionally in Genesis”

  1. I set up a page with the portfolio template from genesis epik theme. I tried all the snippets with the epik theme, but it won’t work. I just want no title only on home.

    If I comment this line out in the template file, the page title for home is gone:
    add_action( ‘genesis_before_content’, ‘genesis_do_post_title’ );

    But how to achieve this via functions snippet?

    1. Brad Dalton Avatar
      Brad Dalton

      You’ll need this for a answer http://wpsites.net/registration/

  2. Thanks for this! Worked perfectly for what I needed to do 🙂

    1. Brad Dalton Avatar
      Brad Dalton

      good stuff

  3. Curious to know how I can conditionally remove post titles / author from *only* a Custom Post Type?

    So many thanks for your post!
    Emily

    1. Brad Dalton Avatar
      Brad Dalton

      CSS would be the easiest way where cpt is the name of your custom post type:
      [code]
      .single-cpt .entry-title {
      display: none;
      }
      [/code]
      Or you can use the conditional tag
      [code]
      is_singular(‘post’) or is_post_type_archive()
      [/code]
      Another option is to use a remove_action in a custom post type template file directly like your single-cpt.php or archive-cpt.php
      [code]
      remove_action( ‘genesis_entry_header’, ‘genesis_do_post_title’ );
      [/code]

      1. perfect, thanks!

  4. Perfect tutorial, thank you very much!

    1. Brad Dalton Avatar
      Brad Dalton

      No worries Jay

  5. This is great.

    How can I remove post meta and post info just from the single posts?

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Mario

      Add a conditional tag after the function

      Examples http://wpsites.net/web-design/modify-post-info-genesis/

  6. kristie Avatar

    Hi. Silly question, but where should i put the code for the “Remove page titles from specific pages”?

    1. Brad Dalton Avatar
      Brad Dalton

      functions file

  7. Is there a simple way to do this maybe using simple hooks? I am trying to remove the HOME from this static home page.

    1. Brad Dalton Avatar
      Brad Dalton

      You can simple remove it from the page title in the Edit screen

      Or you could use CSS code:

      [code]
      .home .entry-title {
      display: none;
      }
      [/code]

      Or you could create a front-page.php template file.

      1. The problem with removing it in the Edit screen is that it removes it from the menu.

        I was told I shouldn’t edit CSS code for genesis?

        I don’t know how to create those php files.

        1. Brad Dalton Avatar
          Brad Dalton

          You can still add it to the menu as a custom link.

          Or you add the CSS code in your child themes style.css file, Not the Genesis style sheet.

          1. Removing it in the Edit Page and then adding it as a Custom Link to the menu seemed to do the trick. Thank you!

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.