I'm developing a theme where home page is organized in sections & made template parts for each one of them. like: hero-home.php, featured-home.php

Now the customizer settings for those sections are also organized in parts & have the same name like hero-home.php, featured-home.php etc....

But the directories are different for the files.

Now is this permitted? bad practice? or my theme will get reject from wordpress.org if I do it like this way?

*** English is not my first language..

  • you can have same file name for templates in different directories, but actual template name should be different
    – Vishwa
    May 9, 2019 at 6:59

1 Answer 1


No matter from which perspective you consider it, it is bad practice to name files the same. To answer your question: Yes, you can do it this way, which doesn't mean that you should it this way. Even you, the developer of the theme, will get confused (I bet some beer or coffee if you want) from time to time when you are not aware of the current file which you are editing.

Your theme will propably not get rejected if the things works a 100%. However, you should stick to WordPress' mentality: code is poetry.

There are lots of options you have, for example:

  • you could prefix (for example: tpl-home.php, etc.) the template files instead of naming them the same.
  • you could name them differently
  • put them in a folder called "template-parts" or something similar

It is recommended to stick to your internal code convention in terms of structure. That way somebody who has downloaded your theme will faster be able to modify it to their needs. Because they don't need to go to university in advance to understand your logic. (you get the idea).

That, in return, will make your theme users happy because they can achieve their goals in terms of layout etc.. Make sure correct translations and child theming is supported/works.

  • Thanks for the suggestion. I have already put them in "template-parts" folder. But you are right different file name helps when you get back to your file after sometime, so you don't get confused & check if it is the right one. May 9, 2019 at 7:27

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.