PHPackages                             cnp/wp-theme-wrapper - 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. cnp/wp-theme-wrapper

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

cnp/wp-theme-wrapper
====================

A wrapper function that intercepts WordPress' template\_include function, allowing us to use base.php instead.

v1.0(10y ago)147MITPHPPHP &gt;=5.3.3

Since Jun 30Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Clark-Nikdel-Powell/WP-Theme-Wrapper)[ Packagist](https://packagist.org/packages/cnp/wp-theme-wrapper)[ Docs](https://github.com/Clark-Nikdel-Powell/WP-Theme-Wrapper)[ RSS](/packages/cnp-wp-theme-wrapper/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

WP-Theme-Wrapper
================

[](#wp-theme-wrapper)

A wrapper function that intercepts WordPress' `template_include` function, allowing us to use base.php instead.

Say you've got two template files for a post type, `archive-book.php` and `single-book.php`. The way that WordPress normally works, you'd have to repeat at least `get_header()` and `get_footer()` in each of these files. Perhaps there's more structural HTML to it. The trouble is, now you have some amount of duplicated code that is not specific to the layout.

The WP Theme Wrapper functions intercept WordPress template selection. Every template uses `base.php`. It then takes the file that *would* have been selected and puts it *into* `base.php`. This way, `archive-book.php` and `single-book.php` only have markup that is specific to the specific view and nothing more.

This also helps us visualize how the template files fit together from start to end; that is, we're not splitting open and close div tags across multiple PHP files.

**Note:** normally, we don't resort to using a WordPress template file, because doing this also overrides `index.php`, The Loop, and all the theme Actions that we've placed around The Loop. You can probably achieve the same effect by using a file structure like `ui/book/book-content-archive.php` and `ui/book/book-content-singular.php`.

#### Reference

[](#reference)

- [March 10, 2017 - Centralizing WordPress Code with a Theme Wrapper, Custom Actions and Layout Classes](https://pagely.com/blog/centralizing-wordpress-code-with-a-theme-wrapper-custom-actions-and-layout-classes/)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

3652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7df60fcdb3fa310756e7ba0e801c8f311e4edf53111a8d09895ead3652fb76a9?d=identicon)[cnp](/maintainers/cnp)

---

Top Contributors

[![jhned](https://avatars.githubusercontent.com/u/2520143?v=4)](https://github.com/jhned "jhned (2 commits)")

### Embed Badge

![Health badge](/badges/cnp-wp-theme-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/cnp-wp-theme-wrapper/health.svg)](https://phpackages.com/packages/cnp-wp-theme-wrapper)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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