PHPackages                             picas/wp-template-hierarchy-everywhere - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. picas/wp-template-hierarchy-everywhere

ActiveWordpress-plugin[Templating &amp; Views](/categories/templating)

picas/wp-template-hierarchy-everywhere
======================================

A WordPress plugin that implements the 'template hierarchy' concept for any template

v1.0.0-beta(10y ago)04GPL-3.0+PHPPHP &gt;=5.3.3

Since Feb 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/e-picas/wp-template-hierarchy-everywhere)[ Packagist](https://packagist.org/packages/picas/wp-template-hierarchy-everywhere)[ Docs](https://github.com/e-picas/wp-template-hierarchy-everywhere)[ RSS](/packages/picas-wp-template-hierarchy-everywhere/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

The WordPress Template Hierarchy Everywhere
===========================================

[](#the-wordpress-template-hierarchy-everywhere)

This plugin is an implementation of [the "template hierarchy" concept of WordPress](https://developer.wordpress.org/themes/basics/template-hierarchy/)for any template.

It redefines some internal methods often used in templates to use the "template hierarchy" concept everywhere: for header, footer, sidebar, search form, sub-templates and assets.

Usage
-----

[](#usage)

### Some new concepts &amp; methods

[](#some-new-concepts--methods)

The plugin first introduces a new concept: the ability to include a template passing it some arguments. This concept is just an enhancement of the [`get_template_part($slug, $name = null)`](https://developer.wordpress.org/reference/functions/get_template_part/)internal function, with a third argument as an array of variables which will be loaded in the template:

```
 get_template_part_fetch($slug, $name = null, $args = array())

```

Actually, the arguments are extracted in the current environment using [the native `extract()` PHP function](http://php.net/manual/function.extract.php).

The plugin also defines a function to get an asset URI (a CSS or JS file for instance), searching it first in an optional child theme (if it exists) and falling back to the parent theme. This allows theme developers to let the final user overwrite one of the theme assets without modifying the original file (please note that this is not the same as overwritting a CSS rule in the child theme's `style.css` file as the original file of the parent theme will not be loaded in our case).

This new function is:

```
 get_asset_uri($name)

```

### The template hierarchy in action

[](#the-template-hierarchy-in-action)

The smart stuff of the plugin is to introduce a new `get_template_part_hierarchical()` function on the same model as the classic `get_template_part()` with an implementation of the template hierarchy concept:

```
 get_template_part_hierarchical($slug, $name = null, $include = true)

```

This function will search a template file following the same rules as for "root templates" (natively concerned by the template hierarchy) and finally fallback to the default WordPress behavior.

As for the enhanced version of including a template fetching it arguments described above, an enhanced version of this new function also exists:

```
 get_template_part_hierarchical_fetch($slug, $name = null, $include = true, $args = array())

```

### The template hierarchy aliases

[](#the-template-hierarchy-aliases)

As the core of WordPress does not allow to use its *hooks* to do so, you will have to use some new methods in replacement of common ones:

original functionnew functionget\_template\_part()get\_template\_part\_hierarchical()get\_footer()get\_footer\_hierarchical()get\_header()get\_header\_hierarchical()get\_sidebar()get\_sidebar\_hierarchical()comments\_template()comments\_template\_hierarchical()get\_search\_form()get\_search\_form\_hierarchical()Have a look at the [manual](https://github.com/e-picas/wp-template-hierarchy-everywhere/blob/master/MANUAL.md)for a development of some of these features.

Installation
------------

[](#installation)

1. Upload the plugin files to the `/wp-content/plugins/wp-template-hierarchy-everywhere` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress
3. You're done

You can also embed a standalone version of this library in a plugin or a theme (internal tests will avoid multi-loading).

Please see the *releases* of the repository to get last version (the `master` branch can have few commits forward but the last release is the best choice).

NOTE - For those who are [Composer](http://getcomposer.org/) users, the package is registered as `picas/wp-template-hierarchy-everywhere`.

Note for developers
-------------------

[](#note-for-developers)

As you will see, I do NOT follow the WordPress coding rules but the PSR (). The WordPress rules just sucks. Period.

Support
-------

[](#support)

If you find a bug, please use the [support panel](https://github.com/e-picas/wp-template-hierarchy-everywhere/issues)of the repository. You may first search in existing issues to check if the bug you figured has not been reported yet.

License
-------

[](#license)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see .

This plugin is made "avec amour" from Paris, France.

```
WP_Template_Hierarchy_Everywhere
Copyright (c) 2016, Pierre Cassat

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3789d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/295156?v=4)[JustCrazy](/maintainers/picas)[@PICAS](https://github.com/PICAS)

---

Top Contributors

[![e-picas](https://avatars.githubusercontent.com/u/1021199?v=4)](https://github.com/e-picas "e-picas (11 commits)")

---

Tags

wordpresstemplatethemetemplate hierarchy

### Embed Badge

![Health badge](/badges/picas-wp-template-hierarchy-everywhere/health.svg)

```
[![Health](https://phpackages.com/badges/picas-wp-template-hierarchy-everywhere/health.svg)](https://phpackages.com/packages/picas-wp-template-hierarchy-everywhere)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[htmlburger/wpemerge-theme

A modern WordPress starter theme which uses the WP Emerge framework

2873.8k](/packages/htmlburger-wpemerge-theme)[pressbooks/pressbooks-book

This theme is named after Canadian media theorist Marshall McLuhan, who coined the phrase “the medium is the message.” It is designed for academic writing and is also suitable for fiction. Headings are set in Cormorant Garamond, and body type is set in Lora.

206.7k](/packages/pressbooks-pressbooks-book)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
