1

When I click on a category now, it looks like..

Category Archives: MyCategory

first post

second post

third post..

I want to customize these landing pages for special categories, add text, pictures, html.

How do I do that, easiest way, w/o plugins. There might be a file to be cloned, like content-category-mycategory.php?

1

Here is the Template Hierarchy, which gives you an overview of the different approaches.

You could create for each category an individual PHP file:

  • either category-{CATEGORY ID}.php
  • or category-{CATEGORY SLUG}.php.

Or you could use a single file category.php in which you define the output (as well as its layout, style etc.) according to the current category - again, either depending on its ID or its slug.

Here's a short example using the ID:

$category = get_the_category();
$cat_ID = $category[0]->cat_ID;
switch ($cat_ID) {
    case 'A':
        ...
        break;
    case 'B':
        ...
        break;
    default:
        ...
}
| improve this answer | |
  • Got stuck finding the Template Hierachy Link... Exactly what I was looking for, easy, fast. Thx – Dan Apr 9 '13 at 17:30
  • @Dan Yeah, unfortunately, the link is not that easy to be found as a search for WordPress templates, for instance, doesn't deliver what you want. You have to search for template hierarchy instead - or just bookmark the page. ;) – tfrommen Apr 9 '13 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.