[wp-hackers] Showing custom page types

Jennifer Hodgdon yahgrp at poplarware.com
Thu Jan 29 20:51:45 GMT 2009


Since you asked for thoughts and suggestions on your plugin code 
(which I won't include again here), here are a few ideas:

a) Calling flush_rewrite_rules() in every 'init' action is not a good 
idea. That means it will happen on every page load for every blog 
visitor, and it's a time-consuming action (well, technically it is the 
rebuild of rewrite rules that is expensive, not the flush itself). You 
probably want to change the logic to flush rewrite rules only when 
necessary, such as when someone changes the config. You might also 
find the 'query_vars' filter and 'generate_rewrite_rules' action to be 
useful to do some of the logic you put into your 'init' action.

b) Besides the 'template_redirect' action, you can also use the 
'parse_request' action to override what WP is planning to do.

c) In your function for the 'template_redirect' action, you can also 
do something like this:

if( logic to detect you are on one of your pages ) {
    include( full path to your desired template file );
    exit;
}

Hope this helps...
     Jennifer

Chris Jean wrote:
> I'm working on a new project that uses WordPress as a framework rather 
> than as just a blogging platform. I want to be able to have custom URL 
> structures, such as /tool/option, that will end up passing variables to 
> a set of code to render the page contents rather than one of the theme 
> template files rendering the content.


-- 
Jennifer Hodgdon * Poplar ProductivityWare
www.poplarware.com

Drupal/WordPress Sites, Themes, Modules/Plugins
Custom Web Programming, Web Databases
PHP, Perl, MySQL, JavaScript, XML, AJAX



More information about the wp-hackers mailing list