0

I do a fair bit with custom API's on WordPress-based sites, typically by creating page templates.

However, creating a custom page template, then creating a WP Page that utilizes it is kind of a pain (not to mention the ugly names I have to use to keep users from deleting or changing them)*.

I prefer the low overhead of plain php files, but then I obviously lose access to WP functions.

Is there a better, more MVC-esque way to get custom logic that can call WP functions firing at specific URLs and yet keep it hidden from the admin?

*I know I can manually un-register pages from the admin, but this is even more of a pain!

0

The template_redirect hook might be what you are looking for.

function template_redir_wpse_97289($content) {
  // code or file include, for example
}
add_filter('template_redirect','template_redir_wpse_97289',1);

That will fire just before the page template is loaded so you could use it to load your own templates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.