Removing Thesis Page Titles With Filters

November 12

Removing Thesis Page Titles With Filters

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.

Thesis Theme for WordPress:  Options Galore and a Helpful Support Community

Image Credit via Flickr

Clip to Evernote

You may also enjoy these related posts:

{ 32 comments… read them below or add one }

Tia November 12, 2010 at 1:33 pm

Thanks, Jim. I’ll look at using this code instead of the other code you’ve provided. Great update.

Cheers,
Tia

Reply

Marla November 30, 2010 at 9:26 am

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.

Reply

Jim December 8, 2010 at 9:35 pm

Glad it worked for you!

Reply

Linda August 28, 2011 at 2:23 am

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

Reply

Jim August 28, 2011 at 5:50 am

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!

Reply

Chase Sagum December 8, 2010 at 7:14 pm

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.

Reply

Jim December 8, 2010 at 9:36 pm

Thanks, I’m glad it fixed your problem and hopefully expanded your Thesis knowledge!

Reply

JulieD January 2, 2011 at 10:30 am

Thanks! The hide a single page worked perfectly for me!

Reply

Jim January 6, 2011 at 9:07 pm

Excellent. Seems to be a good way to do it! Thanks for the comment!

Reply

Nat Couropmitree January 6, 2011 at 4:46 pm

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.

Reply

Jim January 6, 2011 at 9:08 pm

Thanks for the comment. Glad it worked for you!

Reply

Trisha January 11, 2011 at 5:05 pm

you made my life easier in 3 minutes. THANK YOU!

Reply

Jim January 21, 2011 at 9:14 pm

Yeah, I like to hear that. Thanks for the note

Reply

Erudition February 3, 2011 at 11:49 am

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?

Reply

Jim February 5, 2011 at 9:05 pm

It goes into your custom.php file via the Admin menu for Thesis.

Reply

Nat Couropmitree February 5, 2011 at 8:52 pm

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

Reply

Jim February 5, 2011 at 9:04 pm

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. ;)

Reply

Hilary February 16, 2011 at 7:59 am

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.

Reply

Jim March 7, 2011 at 5:22 am

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.

Reply

Regina Velie July 20, 2011 at 2:42 pm

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.

Reply

Mark March 7, 2011 at 7:29 am

Thanks very much. I had a hard time finding a satisfactory solution to this problem, but this worked perfectly.

Reply

Jim March 29, 2011 at 12:14 pm

Glad it helped. Thanks for the note!

Reply

Rex April 13, 2011 at 8:17 am

Great article. Easy and works like a charm.

Reply

Mark H May 5, 2011 at 9:37 am

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!

Reply

Incoterms 2010 from Incoterms 2010 May 22, 2011 at 7:08 am

Thank you Jim, I’m using your code in my site, it’s being a great time saver.

Esteve.

Reply

Jim May 22, 2011 at 9:30 am

I’m glad it helped!

Reply

Angela from Absolute Webmasters June 24, 2011 at 7:14 am

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

Reply

Shaiq Uddin July 4, 2011 at 2:51 pm

Great Jim! This worked like a magic… :)

Reply

Nadia Korths July 28, 2011 at 9:00 am

Thanks for this bit of code. In less than 3 minutes. Beautiful.

Reply

Matthew August 25, 2011 at 3:43 am

Thanks Jim! Easiest addition to my custom_functions.php file :)

No default heading on my homepage now woohoo!

Reply

Brent November 9, 2011 at 6:35 am

Thanks a ton, this worked like a charm first time. Great, easy to follow instructions.

Reply

Tracy November 18, 2011 at 2:04 pm

Wow, if I could get it to work…anyone can. Thanks a million!!

Reply

Leave a Comment

*