
I see a lot of repeated questions on the best way to hide Page Titles in Thesis, so I guess it must be a pretty common issue.
While there are a bunch of ways to do it which either require hacking PHP code (which is prone to breaking something) or hiding it in CSS (which may impact your search rankings) I have never been fully satisfied with them. But, as usual, there is a better way–using Thesis Filters.
Note: I have written about this before here, but I was never satisfied with the methods proposed. So for a better way, read on.
What is a WordPress filter?
You can read all about Thesis Filters here and access the library of functions which allow you access the code to do other fabulous tricks to amuse your family.
Given the number of available places to apply filters, often the trick can be finding the right one for the job. Fortunately, there is very specific area which gives us direct laser-targeted precision directly to the headline area of any post or page.
The Problem
By default, any post or page will display a section entitled Headline Area. The HTML looks like this:
<div class="headline_area"> <h1 class="entry-title">The Title</h1> <p class="headline_meta"><abbr title="2010-11-12" class="published">November 12</abbr></p> </div>But what if we won’t want a title displayed on our Pages as is often the case when you are building non-blog site. There isn’t any good way at the Page-level to remove titles.
The Solution
What we want to do is remove the whole section starting with the outer div. We also want this removed before it is even served up to your HTML page, so this is where custom filters come in handy. The next step is to write our own filter to process and remove the section.
Here are 3 working examples which apply a filter to the thesis_show_headline_area function. You can cut and paste these into your custom_funtion.php file as-is and they will work fine. Just pick one
Code Examples
How to Use This Code
Warning and Disclaimer: There is some PHP coding required, but it’s pretty easy to do. But it’s also easy to miss a closing bracket and cause your site to go dark. If you break your site, I am not responsible for the damage. You’ve been warned. (FTP is your friend in case of emergency.) When in doubt, Read the Friendly Manual or visit the Thesis Forums.
Go to your Thesis Custom File editor menu, select the custom_function.php from the list and select the Edit Selected File button to display your custom_function file.
If you’ve never made changes to this file, you can go to the very bottom of the file and copy & paste in one of the following code blocks.
Version 1 – Hide all page titles
As the name implies, this will hide it on any page on your site, but not on single post pages or the home page.
function suppress_title() {
return (is_page()) ? false : true;
}
add_filter('thesis_show_headline_area', 'suppress_title');
Version 2 – Hide a single page title by Page ID
Want to know how to find the Page ID in WordPress?
This allows you to specify a page by its ID. Useful if you only want to hide on a single page.
function suppress_title() {
return (is_page('32')) ? false : true;
}
add_filter('thesis_show_headline_area', 'suppress_title');
Version 3, hide multiple pages specified by title and/or Post ID
Want to know how to find the Page ID in WordPress?
Lastly, you can specify an array of Page IDs, Page Titles or Page Slugs. Pretty fancy huh? You can specify any number of additional pages by appending values to the array.
function suppress_title() {
return (is_page(array('35','Contact','Directions','all-about-me-page'))) ? false : true;
}
add_filter('thesis_show_headline_area', 'suppress_title');
What The Code Does
Each time WordPress builds the page to display, it checks to see if it’s of type Page, if it is then it just removes the headline area from the code. This way no CSS tricks are needed and we can just forget about this on our single pages. Nice, eh?
If you get stuck, here is the WordPress codex information on using the WordPress is_page function.
Good luck!
If you have found any other good uses for filters, leave a comment.
Image Credit via Flickr


{ 32 comments… read them below or add one }
Thanks, Jim. I’ll look at using this code instead of the other code you’ve provided. Great update.
Cheers,
Tia
Dear Mr. Munro,
I’m using my website as a testing site, (it’s ugly!) and I’m uneasy about learning all this behind the scenes coding. I’m so grateful for your article; I’ve used the code to get rid of those pesky page titles, and now I’m able to include more info on the first fold–the way a website should look.
Glad it worked for you!
Hi Jim, how does this work for category titles? I am having a problem with wp ecommerce where my category pages are reflecting the title of the last product rather than the category title. I tried your code, substituting is_category, but that did nothing? Any ideas?
thanks, Linda
I suspect your commerce plugin changes behaviors and I am not sure how this would affect it. Maybe try to get in touch with the plugin author. Good luck!
Jim this tutorial is AWESOME! Much needed. I actually came just needing to eliminate the post title altogether, but even better learning how to eliminate it on a page by page basis. Exactly what I needed. Thanks so much.
Keep up the Thesis tutorials. Seriously man I don’t think there will ever be a shortage of those.
Thanks, I’m glad it fixed your problem and hopefully expanded your Thesis knowledge!
Thanks! The hide a single page worked perfectly for me!
Excellent. Seems to be a good way to do it! Thanks for the comment!
It worked! I used version 3. Thanks so much Jim. Your instruction was also easiest to understand compared to other sites that provided a fix.
Thanks for the comment. Glad it worked for you!
you made my life easier in 3 minutes. THANK YOU!
Yeah, I like to hear that. Thanks for the note
I just purchased thesis themes and before i switch it over to this new theme I am trying to hide the title on certain pages. I am using thesis hooks, where do I put your code?
It goes into your custom.php file via the Admin menu for Thesis.
Hi Jim,
Is there any reason why your above code may not work on older versions of Thesis? Just trying to figure this out. I used your code on 1 site and it worked perfectly. But on an older thesis site (v.1.6), it doesn’t work.
I suppose I could just upgrade. But thought I would ask.
thanks.
Nat
Yes, it’s highly likely. I have not used 1.6 in quite awhile and I haven’t tested with anything earlier than 1.8. I should have noted this in the beginning. Sorry about that.
I would upgrade if you can.
Hi Jim! I came across your post as I search to find an answer on how to remove page titles from category pages. Would this also work on category pages, or is there something different that would need to be done? Thanks in advance for any thoughts/insight you can provide.
You can use the same logic, but the category pages are targeted with the is_category WordPress function. Just replace is_page with that and it should work. I haven’t tried it, so you may have to alter it slightly, but it’s a starting point.
There are more details on is_category at the WordPress Codex.
Woohoo! Thanks so much.
I got rid of category page titles by replacing
is_category for is_page
and thesis_archive_intro_headline for thesis_show_headline_area
Thanks for your work! I’ve been trying to solve this for a while now.
Thanks very much. I had a hard time finding a satisfactory solution to this problem, but this worked perfectly.
Glad it helped. Thanks for the note!
Great article. Easy and works like a charm.
Thanks for the tips, code worked for me! This really helped me with my last client. Sometimes the page titles just take up too much space. I’ve learned that web design is definitely an on-going process!
Thank you Jim, I’m using your code in my site, it’s being a great time saver.
Esteve.
I’m glad it helped!
Thank you, thank you thank you. I’ve been looking for a way to ditch the annoying page titles. Worked like a charm.
Much appreciated
Angela
Great Jim! This worked like a magic…
Thanks for this bit of code. In less than 3 minutes. Beautiful.
Thanks Jim! Easiest addition to my custom_functions.php file
No default heading on my homepage now woohoo!
Thanks a ton, this worked like a charm first time. Great, easy to follow instructions.
Wow, if I could get it to work…anyone can. Thanks a million!!