Sarathlal N

Remove page title using filter - WordPress

In some situations, I have to remove / hide WordPress page titles for specific pages.

There is too many options to hide or remove page titles.

  1. Hide page titles using CSS
  2. Use conditional statements in template files
  3. Use filter hook

I most prefer the last option (Use filter hook) to remove the page titles because it is simple and the clean one.

We have to add a small code snippet in our theme’s functions.php file.

//Remove page title from my account page
add_filter( 'the_title', 'remove_page_title', 10, 2 );
function remove_page_title( $title, $id ) {
	$hide_title_page_ids = array(7,17,53);//Page IDs
	foreach($hide_title_page_ids as $page_id) {
		if( $page_id == $id ) return '';
	}
	return $title;
}

Looking for a skilled WordPress/WooCommerce developer? I'm currently available for freelance, contract, or full-time remote opportunities! Let's create something amazing together. Send me a quick message, and I'll respond within 24 hours!

Recent Posts

  1. Automating Code Linting with GitHub Actions for WordPress Plugins
  2. Comprehensive Guide to Linting PHP, JavaScript, and CSS in WordPress Plugins Using Composer
  3. The Ultimate Guide to Indexing in Database Design
  4. Understanding 'update_meta_cache' in WordPress - When to Use It, When Not to, and Its Impact on Database Queries
  5. A Guide to Configuring JavaScript and SCSS Paths in WordPress Plugins with @wordpress/scripts

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.