2017 © Pedro Peláez
 

library wp-theme-wrapper

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

image

cnp/wp-theme-wrapper

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

  • Thursday, February 1, 2018
  • by cnp
  • Repository
  • 3 Watchers
  • 1 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

WP-Theme-Wrapper

A wrapper function that intercepts WordPress' template_include function, allowing us to use base.php instead., (*1)

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., (*2)

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., (*3)

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., (*4)

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., (*5)

Reference

The Versions

01/02 2018

dev-master

9999999-dev https://github.com/Clark-Nikdel-Powell/WP-Theme-Wrapper

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

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

30/06 2016

v1.0

1.0.0.0 https://github.com/Clark-Nikdel-Powell/WP-Theme-Wrapper

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

  Sources   Download

MIT

The Requires

  • php >=5.3.3