[wp-hackers] "Right" way to provide a single, customised page

David Anderson david at wordshell.net
Wed Jan 2 14:32:17 UTC 2013


Hi,

I'm coding a plugin for a client, and they have a need for the plugin to 
provide page to be accessed through special links.

I want the plugin to not need much setup; I don't want to include "set 
up a blank page, put in a shortcode, enter the page details into the 
plugin settings" in the instructions. And I'd rather not automate that 
either, surprising them with new pages.

So, what's the 'optimal' way to achieve this? After lots of Googling and 
Codexing, the method I've ended up using is for my 'special page' to be 
accessed via a GET parameter, and a function something like so:

     function my_filter_content($content) {
         if( is_singular() && is_main_query() && isset($_GET['magic']) ) {
             return '<p>This is the magic content!</p>';
         }
         return $content;
     }
     add_filter('the_content', 'my_filter_content');

But perhaps someone knows a better way, or a reason why the above is 
non-optimal?

Thanks,
David

-- 
WordShell - WordPress fast from the CLI - www.wordshell.net



More information about the wp-hackers mailing list