1

If you're familiar with Wordpress, then you already know that Pages have an area to select a template while Posts do not. As well, archive.php and many other pages are handled by a default listing template. These are handled through custom theme development if one wants them to look different.

My question is, "Why?"

Was this simply a design decision during the early years of WP development? Why can the Posts page not also have that same template selection area that Pages has? Why can Categories also not have this selection area?

The answers I'm looking for are mostly from a technical perspective. I've looked through the code and I can't see any reason that posts, etc, can't also benefit from being able to select a preferred template. I also don't understand why having to do this for posts still requires an elaborate development process rather than a simple drop down interface available to pages that allows one to access templates that already work perfectly fine.

As such, I'm endeavoring to write a plugin that solves this issue, but I'm looking for technical caveats I may have missed from others who are much more familiar with the code than I am.

If you know of any plugins that already address this successfully, please add those in the comments as I'd like to take a look at their code.

1

If you would like all Post Types to have template selection functionality, please update to WordPress version 4.7.

Quoted from the codex page linked above:

Page Templates for Post Types Add support for post type templates.

Add support for post type templates. By opening up the page template functionality to all post types, theme developers have even more flexibility with the WordPress template hierarchy (read more).

As far as having custom template for other areas of your WordPress website; Please refer to the following useful links:

  1. Developers :: Theme Handbook OR Codex :: Theme Development
  2. Developers :: Theme Handbook :: Theme Basics :: Template Files OR Codex :: Templates
  3. Developers :: Theme Handbook :: Theme Basics :: Template Files :: Template Files Section
  • What amazing timing. Thank you for that!! I've been doing a lot of research since you posted about the 4.7 changes. This works great for posts, and I've already implemented it on my site. Do you know if this works for archives, etc? Doesn't seem to be a lot out there yet to confirm one way or another. Please post any other resources if you know of any. Thanks again! – user658182 Dec 21 '16 at 20:21
  • @user658182 This functionality only works on "post objects". Other templates must be handled similarly (with template files). However, there's no "drop down menu" anywhere within the administration UI to selectively choose between templates for anything but "post objects". If you're a more "visual" person, here's an excellent resource to better understand the WordPress template hierarchy. – Michael Ecklund Jan 2 '17 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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