0

I divided the website i am making in diferent template files for example: Category for blog -> category-blog.php Category for projects -> category-projects.php But now I am using the POLYLANG plug in to make the translations. I've noticed that while i am creating the respective category in other languages the template does not apply for example category-blog.php file does not apply to the category-blog.php in other languages. Is any way that i can use the same category template file to multiple categories?? more specifically to the translations of the same category ?

Sorry if my questions seems confusing !

Thanks in advance !

4
  • which theme do you use ?
    – Kaperto
    Commented Dec 20, 2019 at 9:45
  • I am using a custom made theme by me :/ (made from scratch) Commented Dec 20, 2019 at 9:47
  • ok I thought the theme may have a special way of handling. but I remember that for the file category-projects.php, the string projects is the slug for the category in one language. then if you have the category projects_spanish, you can create the file category-projects_spanish.php and put inside <?php require "category-projects.php";
    – Kaperto
    Commented Dec 20, 2019 at 10:15
  • That's what i am trying to avoid i followed this tutorial digitalize.ca/2009/06/… Commented Dec 20, 2019 at 11:50

1 Answer 1

0

One option is to create a single category.php file with conditionals. So, you would have something like this:

<?php
if(is_category('one') || is_category('un') {
// your code here
} elseif(is_category('two') || is_category('deux') {
// your code here
}
?>

This way you can still output different code per category, but you won't have to copy category-one.php to category-un.php etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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