What is WordPress’ routing architecture and how do you trace a file by URL?
How would you go about routing a URL to a specific PHP file or PHP function. e.g. www.my-site.com/abc
executes function xyz_function()
in file xyz_file.php
?
Leave a Reply
You must be logged in to post a comment.
WordPress doesn’t use routing the way many other frameworks do. Instead, WordPress uses hooks, filters and it’s templating system.
It would be better to learn this sytem and do things “the WordPress way.” If instead, you still wish to build something like this, you’ll have to build a plugin that will do the work for you.
You could start by hooking the ‘template_redirect’ action. In your callback, you can evaluate the contents of the URL and check to see if there is a template file and/or function defined that matches the routing scheme you want to establish. If you detect that this exists, then call the function.