Which php file lists all the post of a category

In my primary menu, I have added a category “News & Events” and when I click this page, I get all the posts of this category. Which php file I have to edit, in order to change some things that I don’t want to appear when the posts are listed in that page?

3 Answers
3

WordPress uses a hierarchy of templates (see the visual overview) which it checks for presence. In your case when showing a category archive it will check for presence the following files in this order and use the first one it finds:

  • category-$slug.php (In your case probably category-news-events.php)
  • category-$id.php
  • category.php
  • archive.php
  • [paged.php] if paged
  • index.php

So if you want to change things for a specific category, you best create a category-$slug.php (copy from category.php). If you want to to modify the general presentation of categories modify category.php directly. If category.php is not present, just use the next existing file according to the hierarchy.

Leave a Comment