When working with an existing child theme, you may find a situation where you will need to take out the page title. Maybe you want to design a custom page heading, or just don’t like how the page title looks above your content.
Either way, you can remove the page title on Genesis themes with this code:
add_action( 'get_header', 'remove_titles_from_pages' ); function remove_titles_from_pages() { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); } |
If you don’t want to remove the title from all pages on your site, you can target specific pages with a conditional tag like this:
add_action( 'get_header', 'remove_titles_from_pages' ); function remove_titles_from_pages() { if ( is_page( array( 'page-slug-1', 'page-slug-2', 'page-slug-3', 'page-slug-4', 'page-slug-5' ) ) ) { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); } } |
If you want to add the title back, but perhaps in a different area on your page, you can add it back using another hook that references the area on the page where you want the title to be displayed.
add_action( 'get_header', 'remove_titles_from_pages' ); function remove_titles_from_pages() { if ( is_page( array( 'page-slug-1', 'page-slug-2', 'page-slug-3', 'page-slug-4', 'page-slug-5' ) ) ) { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_site_description', 'genesis_do_post_title' ); } } |
The code above will remove the title from the original location (‘genesis_entry_header’) and add it back in the site description area (‘genesis_site_description’). You can move it around to other areas if you want by changing the ‘genesis_site_description’ hook. Check out the Genesis Visual Hook Guide for other locations.
Leave a Reply