• 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

    (@mrosfy)

    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

    (@jordesign)

    Hi @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

    (@mrosfy)

    Thank you @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

    (@jordesign)

    Hey @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

    (@mrosfy)

    Hi @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

    (@jordesign)

    Hi @mrosfy – there’s nothing I’m aware of in the Codex – but one place you could as is in the general/advanced forums.

    https://www.ads-software.com/support/forum/wp-advanced/?view=all

    Thread Starter Mauro Vicariotto

    (@mrosfy)

    Thank you @jordesign

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘category.php template’ is closed to new replies.