• Looking to start an Amazon Affiliate Store?

    Associate-O-Matic

Using the Category-Icons plugin and Thematic to create custom category pages

I am working on a website redesign project for a company that has a need to display several thousand products on their site. One of the main goals with this redesign was easier navigation for the end user. This post will focus on only one aspect of this new navigation. The display of categories.

The desire was to display these product posts and their categories like an online catalog without the need for e-commerce capability. This meant that the categories needed a more visual display instead of a standard list, and this needed to be included on category archive pages. To achieve this, I turned to the Thematic theme framework, category page templates, and most important for my visual layout, the Category-Icons plugin by Sub.

Creating Category Page Templates

The first thing I did was create category page templates. There were two reasons for this:

  1. This site has 85 seperate categories and several category archive pages needed different descriptions at the top of the page.
  2. Each category archive page needed a different loop to pull in different categories of my choosing.

It couldn’t be easier to create category page templates really. Two simple steps:

  1. Copy the category.php file from the main Thematic folder, put it in your Child Theme folder, and rename it using the ID of the category you want to use it for. Learn more here http://codex.wordpress.org/Category_Templates
  2. That’s it, you’ve just created a category template page. Now you can edit this page to include content specific to that category.

Here’s a quick example. I have a category named Bath. This category has an ID of 62. I copied the category.php file into my Child Theme folder and named it category-62.php. Now everytime the Bath category archive page loads, it uses the category-62.php file instead of the category.php file.

Category Page Templates

Adding Custom Content to Category Page Templates

Now I needed to change the content for the Bath category page, so I dove into the template and placed some descriptive content at the top:

[sourcecode="html"]

You've spent hours pouring over magazines to find the perfect design for your new
spa-like bathroom retreat. You've chosen the perfect tile, the whirlpool tub,
beautiful faucets and luxurious shower sprays.

[/sourcecode]

Notice the ascii code in there? I had to use that for the apostrophe’s in order for the page to render correctly. But I digress…

Now for the really cool part. Changing the category loop to pull in the categories of my choosing and to display the icons I assigned to these categories using the Category-Icons plugin. (I’ll go into more detail about this plugin in a future post).

[sourcecode="php"] //Create a variable with category IDs. These can easily be changed anytime.
$ftchildcats="69,71,77,75,67,116,72";
?>

//Creating my own ul class for styling these category listings
echo "

    “;
    //Checking to see if the Category-Icons plugin function exists

    if (function_exists(‘put_cat_icons’))
    //If it does exist, display the Category-Icons along with the category titles
    put_cat_icons( wp_list_categories(‘title_li=&include=’ . $ftchildcats . ‘&echo=0′));
    //If the Category-Icons plugin is broken, or doesn’t exist, just show the full category list
    else
    wp_list_categories(‘title_li’);
    echo “

;
?>[/sourcecode]

The output looks like this:

Category Icons

Category Icons

Of course this is only one of the methods you can use with the Category-Icons plugin. You can learn more here.

If you’re using this plugin, please post a link so we can all have a peek.

This entry was posted in Extend Wordpress, Featured, Plugins, WordPress Tutorials. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. rgregory
    Posted August 14, 2009 at 8:21 pm | Permalink

    Been a long time WPM, I’m liking your return to simple tuts. You keep this up and I’ll keep reading!

    I’ll check this technique out. One question though, why would you need the catalog but no e-commerce?

  2. Posted August 15, 2009 at 7:49 am | Permalink

    @ rgregory,

    Thanks, I’ve been busy with this latest project and others, but my plan is to keep posting more tutorials as much as possible. To your question…the products are only sold through distributors.

  3. Lisa
    Posted September 7, 2009 at 7:54 pm | Permalink

    I’ll be needing this in the near future so I hope you keep up with the tutorials. Also, in light of the use of Series, in your situation, would you think it best practice to use Series and Category separately or in combination?

  4. Michelle
    Posted October 4, 2009 at 11:59 pm | Permalink

    Hi, just wondering where exactly the code above goes? I’m not sure how to change the loop. Thanks

  5. Posted October 5, 2009 at 8:47 am | Permalink

    @ Lisa – I’m not quite sure about your question. Everything above is done with categories.

    @Michelle – If you’re using the Thematic theme framework, you should have created a Child Theme. The code above goes into the category template page in your child theme directory. Does that make sense? If not, please let me know.

One Trackback

  1. By Create Custom Category Pages in Thematic on November 25, 2009 at 2:03 pm

    [...] Warner over at WordPress Modder teaches you how to use the category icons plugin to create custom category pages in Thematic. In the article, Adam goes [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Advertise Here

    Interested in advertising your site or service? Drop me a line here.