WordPress Category Page

From Wiki @ Karl Jones dot com
Revision as of 18:13, 1 November 2016 by Karl Jones (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In WordPress, a Category page (also Category Archive page) displays Posts which belong to a specific WordPress Category.

Category pages are WordPress Templates, related to Archive pages.


Template hierarchy

In the WordPress Template hierarchy, Category pages override the template file named archive.php.

In the case of categories, the hierarchy is fairly simple.

For instance, suppose the slug of the Category in question is news and the Category ID is 6. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme's directory from the following list:

  • category-slug.php
  • category-ID.php
  • category.php
  • archive.php
  • index.php

That is, if you do not have a category-slug.php (lets say category-news.php), WordPress will check for a category-ID.php (like category-6.php), and so on.

So, if you want to make the Category whose ID number is 6 look different from what it is currently (and different from other Category pages), you would want to create a category-6.php file.

If you want to make all Category pages look different from other archive pages (such as date and author archives), then you would want to create or modify the category.php file.

If you want to make changes to the look of all archive pages, you can create or modify the archive.php file.

If you modify the index.php file, you will affect your entire blog.

If you need to create a new file, it is a good idea to copy it from the next file in the hierarchy that exists. For instance, if you want a special display for Category 6, begin by copying the category.php file, or if you don't have one, use archive.php, and so on.

See also

External links