Download the PHP package cnp/wp-theme-wrapper without Composer
On this page you can find all versions of the php package cnp/wp-theme-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cnp/wp-theme-wrapper
More information about cnp/wp-theme-wrapper
Files in cnp/wp-theme-wrapper
Package wp-theme-wrapper
Short Description A wrapper function that intercepts WordPress' template_include function, allowing us to use base.php instead.
License MIT
Homepage https://github.com/Clark-Nikdel-Powell/WP-Theme-Wrapper
Informations about the package 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
.