Custom Page vs Plugin Slug Custom Page vs Plugin Slug wordpress wordpress

Custom Page vs Plugin Slug


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).