• Hi,
    I enjoy working with WordPress, and there’s some issues that I come up against every time I develop a theme which I have to hack around to make it work properly.

    I would like to see a way to enable configuring the template hierarchy so that the developer can assign file names and paths for each of the files in the hierarchy. I do not propose a change in the structure, simply a way to manually assign the paths.

    For instance, when I’m building a WordPress App, I would like the blog page to be nicely organized in the app structure, and easily findable by those not acquainted with the convoluted lineage WordPress template hierarchy.

    Case in point – the home.php is the root for the blog page. This name home.php doesn’t make sense, and even having used WordPress for years now, it’s never intuitive and I always have to refer to the documentation to recall it.

    I like to keep the blog page at a location such as this, organized with the other partials:
    theme/views/blog/index.php As it currently is, I end up just using home.php to include the custom location of the file using locate_template().

    It would be extremely useful and very helpful to have the ability to configure the template hierarchy in the wp-config, and this would result in an un-polluted base directory for the theme.

    For instance, a proposed structure is:

    array(
    	'home'			=>	'views/blog/index.php',
    	'archive'		=>	'views/archive/index.php',
    	'archive-cpt'	=>	'views/archive/index-cpt.php',
    	'single'		=>	'views/blog/single.php',
    )

    Then when searching for over-riding templates for custom post types, if the path for an index for a custom post type isn’t assigned, it will automatically use the location of the assigned base template, appending the -cpt to the end of the base name. For instance, by simply assigning single as views/blog/single.php, it will know to search for single-cpt at views/blog/single-cpt.php and fallback to views/blog/single.php if that isn’t found.

    I am open to making this contribution to the WordPress core if there is support.

  • The topic ‘Option to Configure Template Heirarchy’ is closed to new replies.