oberonlai / wp-router
Adding router for WordPress.
v1.0.0
2021-07-22 03:04 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2026-03-16 14:03:57 UTC
README
Easily add custom URL endpoints in WordPress. Map a url to a function. Modifed from wordpress-dispatcher
Requirements
Installation
Install with composer
Run the following in your terminal to install with Composer.
$ composer require oberonlai/wp-router
WP Router PSR-4 autoloading and can be used with the Composer's autoloader. Below is a basic example of getting started, though your setup may be different depending on how you are using Composer.
require __DIR__ . '/vendor/autoload.php';
use ODS\Router;
Router::routes( array() );
See Composer's basic usage guide for details on working with Composer and autoloading.
Example
use ODS\Router;
Router::routes(
array (
'testing-a-url' => function(){
echo 'Hello Ted';
},
'hello-([a-z]+)' => function($request, $name){
echo "Hello $name";
}
)
);
/testing-a-url & /hello-dougle will now be accessable in your WordPress site.