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.
Leave a Reply
You must be logged in to post a comment.