The power of Thematic hooks

As I begin to wrap up my first child theme using the Thematic framework, I must admit that I’m beginning to really appreciate the power of theme hooks. At first I was modifying the css to get where I wanted to be, for example altering margins, using the background url directive to add my custom header image. But when I got to the point where I wanted to suppress the display of the blog title and description, that is when I first found out about Thematic add and remove actions.

Oh sure I could have just used “display: none” in the css blog title class/ids so that the blog title didn’t display over my custom image, but that’s kind of ugly. Using remove_action in my functions.php file is much more elegant.

function suppress_header_elements() {
remove_action('thematic_header','thematic_blogtitle',3);
remove_action('thematic_header','thematic_blogdescription',5);
}
add_action('init','suppress_header_elements');

And the bonus is that the blog title description value still populate my title and meta description tags as desired for SEO optimization.

Theme hooks is not a concept unique to Thematic but embedded in WordPress itself. Using theme hooks in your child theme, the idea is that you can isolate your customizations in a single file in a functions.php file (it may be called something different such as custom_functions.php with other frameworks).

Although I had altered the css to add my image, I wanted to additionally add clickable button images as well that I already had defined in a css file. No problem, I just created a new function called add_buttons in my functions.php file, echo’ed out the HTML and then added the add_action line:

function add_buttons() {
echo ....
}
add_action('thematic_header', 'add_buttons');

It wasn’t completely smooth sailing as I ran into this error when I tried to use the admin (error text modified to remove site identifying info)

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/blog/wp-content/themes/childtheme/functions.php:43) in /home/mysite/public_html/mysite.com/blog/wp-includes/pluggable.php on line 865

Most of the information you get googling this error suggests there is extra spaces prior to the php start tag in the wpconfig.php file. That wasn’t the case here, but it was a good clue. Turns out I had an extra blank line after the closing php tag in my functions.php file. When I finally figured out to remove that, the errors went away.

About the Author Kathy Alice

Kathy Alice Brown is a traffic and conversion expert specializing in SEO, Copywriting and Facebook Ad Campaigns. In her spare time she loves to get outside.

Leave a Comment:

2 comments
mbt shoes says May 11, 2010

Great article Thank

you so much!

Reply
how to make money blogging says September 14, 2010

Really wonderful post. this blog is awesome.Posts with more information will be great.

Reply
Add Your Reply