Thesis Tip #12 – Adding Custom Headers to Category Pages

by Bill Erickson on February 21, 2010

Post image for Thesis Tip #12 – Adding Custom Headers to Category Pages

You can add introductory text to the top of your category page by using the thesis_hook_archive_info hook.

For the following example, we’re assuming you have two categories for which you’d like intros, with the category slugs of category-1 and category-2. You can use category names, id’s or slugs for this. See The Codex and scroll down to is_category for more information on usage.

In custom_functions.php:

function category_intro() {
if(is_category('category-1')) { ?>
<p>This is the intro text for Category 1</p>
<?php }else if(is_category('category-2')) { ?>
<p>This is the intro text for Category 2</p>
<?php }
}
add_action('thesis_hook_archive_info','category_intro');

This will add the block of text above all the posts, but below the archive_info div (the part that says “From the Category Archives”) . You also might want to hide the archive_info div by putting this in your custom.css file:

.custom #archive_info {display:none;}

All Thesis Tips:

Bill Erickson is a WordPress Consultant who builds custom websites using WordPress as a CMS and Thesis or Genesis as a framework. He’s a cofounder and resident of The Creative Space, and a cofounder of the BIL Conference (the open analog to the TED Conference).

{ 2 comments… read them below or add one }

Carlo May 19, 2010 at 5:45 pm

Awesome, exactly what I was looking for. Thanks!

Reply

MikeK August 3, 2010 at 11:03 pm

I looked high and low for this info and this is by far the simplest and most elegant solution. Thanks so much!!

Reply

Leave a Comment

Previous post:

Next post: