Genesis Theme – Remove Titles from All Pages Except the Blog

This is a really short specific post for WordPress Genesis theme users. We posted this after working on our own WordPress site. Thought it would be useful for WordPress developers. You’re probably finding this post because you wanted to remove the H1 page title that displays automatically on your pages, but you want to keep the entry title showing for your post excerpts on your blog. Here’s how you do that.

How to remove the page title from all pages except the blog

This covers how to remove the entry title from pages, not posts.

Step 1: Make sure you have access to your FTP

This is useful if you’re not super confident about making PHP updates. You’ll need to be able to correct your functions.php file via FTP if you make a mistake in the WordPress admin and bring your site down.

Step 2: Find the page id for your blog

HTML source code of a WordPress blog page showing the page id location.
We want to know the number of the page-id for this page. In this case, it’s 549.

Go to your blog page. View the source and search for page-id. Find the number that is listed after page-id. Remember this number.

Step 3: Update your Theme Functions.php file

OK, now go into functions.php file. You can do this through Appearance -> Editor or through FTP and it will be in your child-theme folder. Go to the bottom and add a new filter that looks like this:
add_action( 'get_header', 'remove_titles_all_single_pages' );
function remove_titles_all_single_pages() {
if ( is_singular('page') !== is_page ('PAGEID NUMBER') ) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
}

Replace that PAGEID_NUMBER with your page-id number for the blog. For example, the filter for this site looks like this:

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

Step 4: Save the functions.php and check your site

Consider double checking your PHP with a PHP validator. Looks good? Alright, go ahead and save the functions.php file. If you’re on FTP, upload it or make sure the one on your server gets updated. Go ahead and check your site. All your pages that are not your blog will have no titles display on the page. The blog will still show entry titles for the blog posts.

Why does this work?

If you care to know, here’s what’s happening. Everything is pretty self explanatory and you can find this code on other sites, but this part needs a little attention:

!== is_page ('549')

The !== part says apply this statement to every single page except the page-id we list. Therefore, we can still see entry titles on the blog.



Author: Graham Onak
Graham Onak is the owner of GainTap, a Chicago based online marketing optimization company. He brings a wide array of experience to his work and writes primarily about technical optimization techniques for websites and online marketing programs.

Leave a Reply