Adding Custom Headers to Category Pages in Thesis

This post has been marked as old. The code might no longer work. Comments have been disabled as this is no longer maintained. Use the search on the right to find a newer tutorial.

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

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

  1. MikeK says

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

  2. Alex says

    Worth pointing out though – this only works with Thesis versions prior to 1.8

    We’ve been using this setup and when we updated to 1.8 the functionality is gone. It’s to do with the improved filters in thesis now as far as we’ve been able to work out.

    That said, if your site’s running an older version of Thesis, this indeed is a great solution

    • Bill Erickson says

      Good catch. I don’t go through my old posts and update them or confirm they work with newer versions of Thesis.

    • Bill Erickson says

      As I noted at the top, this hook was removed in version 1.8, which is why it’s not listed with the rest of the hooks.

      • Kat says

        And how does one remove the default title of the cat at the top of the page? I can’t seem to remove it…

        • Bill Erickson says

          I’ve never tried it, but I assume if you go to Categories > Edit and set the Intro Title to ” ” it would show up blank.

            • Bill Erickson says

              Since I don’t work with Thesis much anymore I don’t know off the top of my head. The easy solution would be to view the source of the page, find out the ID or class wrapping around the category title, and dropping it into your custom.css file with display: none.

              The more difficult but better solution is to dig through the thesis code and find where the category intro box is being generated and look for any hooks or filters you could use to remove it.

  3. Chris. says

    I’m having trouble with thesis 1.8 and wp 3.1 (as other people are on the thesis forums) where there are two places to put intro and heading info when editing a category, and then neither shows up for me on my archive page. I’m assuming this will be fixed soon, but in the mean time I’m using your code and changing the add_action element to:

    add_action(‘thesis_hook_before_content’,’category_intro’);

    Again this problem has been flagged at diythemes and will probably be fixed in the next version, but until then…

  4. Audrey says

    Do you know if it’s possible to add custom headers and content to category pages using Genesis?

    • Bill Erickson says

      Yes, if you go to Posts > Categories and click on a Category, you’ll be able to provide a title and description to be displayed at the top.

      • Audrey says

        So this title and description (e.g., introduction) will appear on the category page when it is viewed. This isn’t just meta data. Is that correct? Thanks for your help with this.

        • Bill Erickson says

          Yes, it will show up at the top of the page in a div called “taxonomy-description”. It will use the category title and category description, NOT the meta title and meta description, which is also editable from this screen.

          • Audrey says

            Sorry to keep asking more questions on this, but had one more question. Will the category description allow images and several paragraphs of text? Looking to do something similar to SugarRae does with her category pages (through thesis). Thanks for your help – it’s much appreciated!

  5. Bill Erickson says

    @Audrey, I don’t think so. It’s probably best to manually write the HTML for that in a function and attach it to the top of the page.

    Create a file called category.php, then put this in it:

    • Haroun Kola says

      Thanks for this, its exactly what a client wants me to do.
      It would be great if StudioPress introduces this to Genesis too 🙂

  6. Darya says

    Dear Bill,
    I simply cant for the life of me figure out how to get rid of the Category Titles on my Category Pages. I have the title “PHOTOS” below my header and above the post here: http://izoominka.com/category/photos/ – I’d like to get rid of it!!! I’ve pasted the code: .custom #archive_info {display:none;} into my custom.css, but it does not work. I use Thesis 1.8 with WordPress 3.1. Praps there is another solution – I couldn’t find anything online. Hope you can help.