Having a template per category? Bad for server overhead?

I understand that you can create (as per the WordPress Hierarchical Structure) a specific template to load a specifc template.

For example:

category-new-york.php

^ this is a priority over simply:

category.php

My question is, would creating a template PER US State be a “bad idea?”

So, I would have:

category-alabama.php 
category-arizona.php 
category-akansas.php

etc etc

I say “bad practice” because perhaps I am just adding a ton of overhead that WordPress has to loop through templates – or is it not a huge problem? Would the overhead be nominal?

Thanks

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I say “bad practice” because perhaps I am just adding a ton of overhead that WordPress has to loop through templates – or is it not a huge problem? Would the overhead be nominal?

No, there won’t be an extra performance cost because that’s not how the template loading works. WP always runs through the template hierarchy from most specific to most generic, testing if the file exists as it goes along. It doesn’t “loop” through them.

As for creating a template for every US state, I would advise against it, mainly because it means your folder will have a lot of files making it difficult to navigate in the editor, and when you want to make a change you have to update every single state.

You’d be better off making a single generic state template, or better yet, add a state taxonomy and create taxonomy-state.php instead of repurposing categories.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x