PHPackages                             johnbillion/extended-template-parts - 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. johnbillion/extended-template-parts

ActiveLibrary[Templating &amp; Views](/categories/templating)

johnbillion/extended-template-parts
===================================

A library which provides extended functionality to WordPress template parts, including template variables and caching.

2.2.2(1y ago)118218.4k—3.3%16[1 issues](https://github.com/johnbillion/extended-template-parts/issues)[1 PRs](https://github.com/johnbillion/extended-template-parts/pulls)1GPL-2.0+PHPPHP ^7 || ^8

Since Jan 25Pushed 1y ago3 watchersCompare

[ Source](https://github.com/johnbillion/extended-template-parts)[ Packagist](https://packagist.org/packages/johnbillion/extended-template-parts)[ Docs](https://github.com/johnbillion/extended-template-parts/)[ RSS](/packages/johnbillion-extended-template-parts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (13)Used By (1)

[![Stable Release](https://camo.githubusercontent.com/4bc0957c941e6ff276eba80351791435e0f0597f840834a258608b9ef6fafcda/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f686e62696c6c696f6e2f657874656e6465642d74656d706c6174652d70617274732e737667)](https://packagist.org/packages/johnbillion/extended-template-parts)[![License](https://camo.githubusercontent.com/ef88f59427736dbb8552a135a673e6d315cb04f50ba43d15d54ab931267371f9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c5f76322532422d626c75652e737667)](https://github.com/johnbillion/extended-template-parts/blob/master/LICENSE)

Extended Template Parts
=======================

[](#extended-template-parts)

Extended Template Parts is a library which provides extended functionality to WordPress template parts, including template variables and fragment caching.

Features
--------

[](#features)

- Pass variables into your template parts and access them via the `$this->vars` array. No polluting of globals!
- Easy optional caching of template parts using transients.

Minimum Requirements
--------------------

[](#minimum-requirements)

**PHP:** 7.0
**WordPress:** 4.4

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

[](#installation)

Extended Template Parts is a developer library, not a plugin, which means you need to include it somewhere in your own project. You can use Composer:

```
composer require johnbillion/extended-template-parts
```

Or you can download the library and include it manually:

```
require_once 'extended-template-parts/extended-template-parts.php';
```

Basic Usage
-----------

[](#basic-usage)

The `get_extended_template_part()` function behaves exactly like [WordPress' `get_template_part()` function](https://developer.wordpress.org/reference/functions/get_template_part/), except it loads the template part from the `template-parts` subdirectory of the theme for better file organisation. The usual parent/child theme hierarchy is respected.

```
get_extended_template_part( 'foo', 'bar' );
```

Use the `$vars` parameter to pass in an associative array of variables to the template part:

```
get_extended_template_part( 'foo', 'bar', [
	'my_variable' => 'Hello, world!',
] );
```

In your `template-parts/foo-bar.php` template part file, you can access the variables that you passed in by using `$this->vars`:

```
echo esc_html( $this->vars['my_variable'] );
```

Advanced Usage
--------------

[](#advanced-usage)

The `get_extended_template_part()` function also accepts a second optional parameter that controls the directory name and caching.

The following code will load `foo-bar.php` from the `my-directory` subdirectory and automatically cache its output in a transient for one hour:

```
get_extended_template_part( 'foo', 'bar', [
	'my_variable' => 'Hello, world!',
], [
	'dir'   => 'my-directory',
	'cache' => 1 * HOUR_IN_SECONDS,
] );
```

License: GPLv2 or later
-----------------------

[](#license-gplv2-or-later)

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 2 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.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance46

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 89.6% 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

Every ~336 days

Recently: every ~487 days

Total

11

Last Release

404d ago

Major Versions

1.1.0 → 2.0.02018-09-27

PHP version history (3 changes)1.0.0PHP &gt;=5.4

2.0.0PHP ^7.0

2.2.0PHP ^7 || ^8

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/208434?v=4)[John Blackbourn](/maintainers/johnbillion)[@johnbillion](https://github.com/johnbillion)

---

Top Contributors

[![johnbillion](https://avatars.githubusercontent.com/u/208434?v=4)](https://github.com/johnbillion "johnbillion (69 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (3 commits)")[![bizmate](https://avatars.githubusercontent.com/u/1427498?v=4)](https://github.com/bizmate "bizmate (2 commits)")[![goldenapples](https://avatars.githubusercontent.com/u/665992?v=4)](https://github.com/goldenapples "goldenapples (1 commits)")[![ibes](https://avatars.githubusercontent.com/u/383277?v=4)](https://github.com/ibes "ibes (1 commits)")[![mattheu](https://avatars.githubusercontent.com/u/494927?v=4)](https://github.com/mattheu "mattheu (1 commits)")

---

Tags

wordpress

### Embed Badge

![Health badge](/badges/johnbillion-extended-template-parts/health.svg)

```
[![Health](https://phpackages.com/badges/johnbillion-extended-template-parts/health.svg)](https://phpackages.com/packages/johnbillion-extended-template-parts)
```

###  Alternatives

[wp-bootstrap/wp-bootstrap-navwalker

A custom WordPress nav walker class to fully implement the Bootstrap 4 navigation style in a custom theme using the WordPress built in menu manager.

3.3k44.3k](/packages/wp-bootstrap-wp-bootstrap-navwalker)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[silverstripe-themes/simple

The SilverStripe simple theme (default SilverStripe 3 theme)

411.3M8](/packages/silverstripe-themes-simple)[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.

216.6k](/packages/pressbooks-pressbooks-book)[mediawiki/vector-skin

Modern version of the MonoBook skin

533.5k](/packages/mediawiki-vector-skin)[frozzare/digster

Twig templates for WordPress

107.1k](/packages/frozzare-digster)

PHPackages © 2026

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