admin管理员组文章数量:1024206
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 if I do it like this way?
*** English is not my first language..
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 if I do it like this way?
*** English is not my first language..
Share Improve this question asked May 9, 2019 at 6:55 Aohor ArsalanAohor Arsalan 32 bronze badges 1- you can have same file name for templates in different directories, but actual template name should be different – Vishwa Commented May 9, 2019 at 6:59
1 Answer
Reset to default 0No 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.
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 if I do it like this way?
*** English is not my first language..
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 if I do it like this way?
*** English is not my first language..
Share Improve this question asked May 9, 2019 at 6:55 Aohor ArsalanAohor Arsalan 32 bronze badges 1- you can have same file name for templates in different directories, but actual template name should be different – Vishwa Commented May 9, 2019 at 6:59
1 Answer
Reset to default 0No 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.
本文标签: theme developmentCan I have two files with same name but different directory
版权声明:本文标题:theme development - Can I have two files with same name but different directory? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745510776a2153816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论