Custom Page vs Plugin Slug

自闭症网瘾萝莉.ら 提交于 2019-12-06 07:41:44
lipson

I ran into this the week while writing a custom API (REST + JSON) for a WordPress site I was working on. My solution was to use a page-template and use that as the entry point for the API. That's when I came across https://stackoverflow.com/a/4975004/1386140. The one catch, though, is that it would require the user (admin of the site) to title the page to match the parameter that the plugin checks against

$wp->query_vars["pagename"] == 'YOUR_PAGE_NAME'

For my purpose, this was more than sufficient, especially since we redirected irrelevant traffic. This allows additional query parameters in the URL, though doesn't play friendly with slugs. Since it will still be called as a typical page methods like get_sidebar() would still work.

To get it to work with slugs, I would look at this post ( https://stackoverflow.com/a/2487407/1386140 ) to get started in the right direction (looks legit, but I haven't worked with custom rewrite rules and plugins before).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!