How to Remove Page Titles in WordPress’s Genesis Theme

GainTap is a Chicago based digital marketing company that builds, manages and customizes WordPress websites. Contact us to learn how we can help your company.

 

This is a really short specific guide that will walk you through how to remove page titles in WordPress’s Genesis theme. We posted this after working on our own WordPress site because we thought it would be useful for WordPress developers.

You likely found this post because you want to remove the H1 page title that’s automatically displayed on pages without removing the entry titles for blog posts. Here’s how to do that:

Step 1: make sure you can access 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 (File Transfer Protocol) 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, which is highlighted in the above screenshot, for this page. It’s 549.

To find the page ID, go to your blog page, view the page source and search for the page-id. Find the number that’s listed after page-id. Remember the number.

Step 3: update your theme’s functions.php file.

OK, now go into your 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 pages other than those on your blog will no longer have titles displayed. The blog will still show entry titles for the blog posts.

Why does this work?

Everything is pretty self-explanatory and you can find this code on other sites, but if you care to know, look closely at this part:

!== 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. It’s that simple.



Leave a Reply