Wednesday 24 July 2013

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 sec-
tions 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 dis-
play of categories.
✦ Add a dash and the category ID number to the end of the filename
to specify a template for an individual category.

✦ If you don’t have a category.php or category-#.php file, the cat-

egory display gets defined from the Main Index template (index.php).

 

0 comments:

Post a Comment