O'Reilly logo

WordPress® All-in-One For Dummies® by Michael Torbert, Andrea Rennick, Kevin Palmer, Cory Miller, Lisa Sabin-Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Template for Each Post Category

You don't have to limit yourself to creating a static-page template for your site. You can use specific templates for the categories you've created on your blog (which we talk about in Book III, Chapter 7) and create unique sections for your site, as Lisa did (with an espresso chaser, of course).

Figure 6-4 shows Lisa's design portfolio. Design Portfolio is the name of a category that she created in the WordPress Dashboard. Instead of using a static page for the display of her portfolio, she used a category template to handle the display of all posts made to the Design Portfolio category.

You can create category templates for all categories in your blog simply by creating template files that have filenames that correspond to the category ID numbers, and then uploading those templates to your WordPress themes directory (see Book VI). Here's the logic to creating category templates:

  • A template that has the filename category.php is a catchall for the display of categories.
  • Add a dash and the category ID number to the end of the filename (shown in Table 6-1) to specify a template for an individual category.
  • If you don't have a category.php or category-#.php file, the category display gets defined from the Main Index template (index.php).

Figure 6-4: Lisa's Design Portfolio page, which uses a category template file.

image

Table 6-1 shows three examples ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required