Skip to Content
WordPress® All-in-One For Dummies®
book

WordPress® All-in-One For Dummies®

by Lisa Sabin-Wilson, Cory Miller, Kevin Palmer, Andrea Rennick, Michael Torbert
April 2011
Beginner to intermediate content levelBeginner to intermediate
908 pages
22h 37m
English
For Dummies
Content preview from WordPress® All-in-One For Dummies®

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

WordPress® 24-Hour Trainer

WordPress® 24-Hour Trainer

George Plumley
Gaming Hacks

Gaming Hacks

Simon Carless

Publisher Resources

ISBN: 9780470877012Purchase book