WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/page template

The "page_template" filter can be used to load a custom template for a given page. It will replace the template used whenever the "page" template is called.

A plugin can register as a content filter with the code:

<?php add_filter( "page_template", "plugin_function_name" ); ?>

Where "plugin_function_name" is the function WordPress should call when the content is being retrieved. Note that the filter function the plugin defines must return the a full path to a template file or the resulting page will be blank. The template file should have the same entries as the "page.php" file has in the theme.

Related

See also index of Function Reference and index of Template Tags.