Creating phantom pages for a plugin
-
I have done a fair amount of hunting and looking through plugins to try and figure out how to create a url scheme which makes wordpress pass on a given path to my plugin. For example:
http://example.com/phantompage/otherstuffhere/etc/
… where any paths which match /phantompage/?/ are passed on to my plugin with little overhead (i.e. db processing for the loop).
I understand that I can hook the filter rewrite_rules_array to add a new path scheme including setting up my query_vars, and then subsequently I can use a template_redirect to select a specific template file which is the target of my phantom page, however I cant figure out how to do this without wordpress assuming the default index.php page and therefore doing database queries for the loop.
I have however seen a few plugins which do a rewrite of their specific url scheme to index.php?pagename=phantompage&foo=bar. I noticed that when you navigate to the rewritten url in wordpress e.g.
http://example.com/index.php?pagename=phantompage&foo=bar
…it infact doesnt throw a 404 (why doesnt this throw a 404?), so using this and then in the template_redirect looking for pagename=phantompage, is this an acceptable way of acheiving what I want?
If that makes any sence, could somebody help me out please?
Many thanks,
Andrew
The topic ‘Creating phantom pages for a plugin’ is closed to new replies.