[wp-hackers] Full-page Plugins

Michael D Adams mikea at turbonet.com
Tue Aug 1 21:06:43 GMT 2006


On Aug 1, 2006, at 12:05 PM, Mike Purvis wrote:

> Hi everyone,
>
> I'm a bit confused about the best way to have a plugin seize control
> of the entire page. I don't want any Loop or posts or anything, I just
> need my plugin to hijack certain requests and then inject arbitrary
> content between the theme's header and footer.
>
> ...Will I need to create my own "page template"...

I have found page templates to be incredibly useful for things you do  
only to your own site but less useful for plugins you plan to  
distribute.  If your plugin makes use of a page template, you'll have  
to have your users upload the plugin to the plugins directory and the  
page template to the correct theme directory.  Plus, your markup  
probably won't match the user's theme, so you'll have to add in your  
own CSS which *also* won't match the theme....

Depending on how much control you really need, the_content, the_posts  
and the various query filters might be enough for you.  This method  
will ensure that most of the markup will be what the user's  
particular theme expects.

If you need more control than that, you can create a custom template  
to be placed in the *plugins* directory and get it to load with the  
template_redirect action.  With this method, you eliminate the  
multiple directory disadvantage found in the page template method but  
not the markup/styling problem.

Also, note that in WP2.1, WP can hijack the front page for you  
(create at least one Page and go to Options->Reading/Front Page or  
directly set the page_on_front option).

Michael


More information about the wp-hackers mailing list