插件中子页面的WordPress URL解析 [英] wordpress url resolution of subpages from within plugin
问题描述
假设我在wordpress中有一个页面"foo",这样http:///www.blah.com/foo就会显示出来.
Say I have a Page "foo" in wordpress such that http:/www.blah.com/foo brings it up.
说此页面的内容内有一个触发器,例如<!-foo-!>我的插件正在通过add_filter('the_content',..)过滤器对其进行跟踪.因此,所有对http:www.blah.com/foo和 http://www.blah的调用.com/foo?var = bar 由插件提取并处理.
Say this page has a trigger within its content such as <!-- foo --!> which is being tracked by my plugin through the add_filter('the_content', ..) filter. So, all calls to http:www.blah.com/foo and http://www.blah.com/foo?var=bar are picked up by the plugin and dealt with.
现在有一种方法可以让插件让wordpress知道它要处理所有类型为"> http:///www.blah.com/foo/bar/morefoo 等. 无需"为每个页面创建页面/子页面,因为这些URL可以动态创建?
Now is there a way by which the plugin could let wordpress know that it wants to handle all urls of the type http://www.blah.com/foo/bar http://www.blah.com/foo/bar/morefoo etc.. "without" having to create pages/subpages for each of these as these urls would be created dynamically?
此外,除了在页面内的the_content上使用add_content过滤器之外,还可以从理想地键入url的插件中获取控制权,因此所有对
Also, is there anyway besides using the add_content filter on the_content within a page that one can grab control from within a plugin ideally keyed of the url so all calls to http://www.blah.com/foo are handled by the plugin.
推荐答案
回答我自己的问题:
上面答案中的指针很有用,它使我走上了正确的轨道,但是我一直遇到一个障碍,因为只要有问题的url被调用,它就会一直调用index.php.
The pointers in the answers above were useful and got me going on the right track, but I kept hitting a snag in that whenever the url in question was invoked it kept calling index.php.
然后我遇到了 http://mikeschinkel.com/博客/restful-web-services-in-wordpress-plugin/ 在其中进行解释并提供答案,需要执行template_redirect操作以确保控件在您想要的位置.
I then came across http://mikeschinkel.com/blog/restful-web-services-in-wordpress-plugin/ where he goes into an explanation and provides an answer that requires a template_redirect action to ensure that control is where you want it.
这篇关于插件中子页面的WordPress URL解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!