Download the PHP package upstatement/routes without Composer
On this page you can find all versions of the php package upstatement/routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download upstatement/routes
More information about upstatement/routes
Files in upstatement/routes
Package routes
Short Description Manage rewrites and routes in WordPress with this dead-simple plugin
License MIT
Homepage https://www.upstatement.com
Informations about the package routes
Routes
Simple routing for WordPress. Designed for usage with Timber
Basic Usage
Using routes makes it easy for you to implement custom pagination — and anything else you might imagine in your wildest dreams of URLs and parameters. OMG so easy!
Some examples
In your functions.php file, this can be called anywhere (don't hook it to init or another action or it might be called too late)
map
Routes::map($pattern, $callback)
Usage
A functions.php
where I want to display custom paginated content:
Arguments
$pattern
(required)
Set a pattern for Routes to match on, by default everything is handled as a string. Any segment that begins with a :
is handled as a variable, for example:
To paginate:
To edit a user:
$callback
A function that should fire when the pattern matches the request. Callback takes one argument which is an array of the parameters passed in the URL.
So in this example: 'info/:name/page/:pg'
, $params would have data for:
$data['name']
$data['pg']
... which you can use in the callback function as a part of your query
load
Routes::load($php_file, $args, $query = null, $status_code = 200)
Arguments
$php_file
(required)
A PHP file to load, in my experience this is usually your archive.php or a generic listing page (but don't worry it can be anything!)
$template_params
Any data you want to send to the resulting view. Example:
$query
The query you want to use, it can accept a string or array just like Timber::get_posts
-- use the standard WP_Query syntax (or a WP_Query object too)
$status_code
Send an optional status code. Defaults to 200 for 'Success/OK'
All versions of routes with dependencies
altorouter/altorouter Version ^2.0.2
composer/installers Version ^1.0 || ^2.0