Adding Custom Headers to Category Pages in Thesis

This is how you can add custom introductory text or images to the top of category pages.

Update: As of Thesis 1.8, this technique no longer works. Now if you want to add introductory text at the top of a category, simply go to Posts > Categories, click "Edit" on the category you want, and add the text (or HTML) to "Introductory Content".

---

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:

[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');[/php]


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;}

No comments yet