Title: category.php template
Last modified: November 21, 2023

---

# category.php template

 *  [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * (@mrosfy)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/)
 * Dear all, for a child theme I need to add a “category” page custom template.
 * My changes will not be about way to categorize posts or taxonomy or else, but
   only in html page design (I have just to add some html content to the body).
 * So I assume I don’t need to work on “category.php” (which are in WP-includes)
   but on “archive.php”: correct? (please kindly confirm).
 * If my above deduction is correct, the job is easy because archive.php is already
   in parent theme and I would replace a copy in my child.
 * But just in case I need to change also category.php (f.e. “category-35.php”):
   where should I add it? These files are only in “WP-includes” but not in “WP-content/
   themes” … could I add in child theme under the folder “template-parts”, or where?
 * Thank you.
 * Mauro

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * (@mrosfy)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17223080)
 * I have solved using the archive.php, adding lines pointing to category ( ‘ID’)
   of my pages. It works well. And category.php is already in the theme, so easy
   to add it in the child-theme.
 * But I’m still interested to know for my curiosity my second question, i.e. where
   should I put a template in case it is missing in the themes root, and actually
   being in wp-includes. My idea is that it could be added in child-theme declaring
   it in functions.php. But wait for your confirmation. Thx.
 *  Moderator [jordesign](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17225763)
 * Hi [@mrosfy](https://wordpress.org/support/users/mrosfy/),
 * > But I’m still interested to know for my curiosity my second question, i.e. 
   > where should I put a template in case it is missing in the themes root, and
   > actually being in wp-includes. My idea is that it could be added in child-theme
   > declaring it in functions.php. But wait for your confirmation. Thx.
 * Glad to hear you figured it out 🙂 To answer your further question – for new 
   templates like `category-35.php` (for example) you could add them to the root
   folder of the Child theme and they’d work from there.
 * Generally speaking – I’d advise against touching anything in the core files (
   like wp-include)
 *  Thread Starter [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * (@mrosfy)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17226967)
 * Thank you [@jordesign](https://wordpress.org/support/users/jordesign/), of course
   I shouldn’t touch the core files.
 * In the same argument I have a further question:
 * to add some h1 text to the template (being text which should be variable, to 
   be updated frequently), may I use the method to add the html piece in the template
   and “`file_get_contents()`” function (+ url) pointing to an external .txt file(
   which is for the variable text)?
 * Or as alternative adding in the wp template something like “`$xxx_string = include('
   text.txt')`;” (+ url), pointing to an external .txt (which should start with “`
   <?php return`“)?
 * Or which is the official wp method to achieve this?
 * Thank you very much.
 *  Moderator [jordesign](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17231052)
 * Hey [@mrosfy](https://wordpress.org/support/users/mrosfy/) – to be honest I’m
   not sure how you would approach that kind of thing (its a little more technical
   than my knowledge).
 * I _think_ file_get_contents() would be a good approach, and including that in
   the template PHP file itself (within a child theme). But i don’t know that there
   is an ‘Official’ WordPress way to do that kind of thing.
 *  Thread Starter [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * (@mrosfy)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17231115)
 * Hi [@jordesign](https://wordpress.org/support/users/jordesign/), thank you for
   your opinion. I’m quite sure that some hook must be planned in WP: they’re always
   so carefully following all possible needs. The point is that I can’t find something
   helpful in Codex … do you know whom should I ask? Any designer or part of WP 
   team?
 *  Moderator [jordesign](https://wordpress.org/support/users/jordesign/)
 * (@jordesign)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17234337)
 * Hi [@mrosfy](https://wordpress.org/support/users/mrosfy/) – there’s nothing I’m
   aware of in the Codex – but one place you could as is in the general/advanced
   forums.
 * [https://wordpress.org/support/forum/wp-advanced/?view=all](https://wordpress.org/support/forum/wp-advanced/?view=all)
 *  Thread Starter [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * (@mrosfy)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17234921)
 * Thank you [@jordesign](https://wordpress.org/support/users/jordesign/)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘category.php template’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/twentyseventeen/4.1/screenshot.
   png)
 * Twenty Seventeen
 * [Support Threads](https://wordpress.org/support/theme/twentyseventeen/)
 * [Active Topics](https://wordpress.org/support/theme/twentyseventeen/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/twentyseventeen/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/twentyseventeen/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Mauro Vicariotto](https://wordpress.org/support/users/mrosfy/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/category-php-template/#post-17234921)
 * Status: not resolved