PHPackages                             upstatement/routes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. upstatement/routes

ActiveLibrary[HTTP &amp; Networking](/categories/http)

upstatement/routes
==================

Manage rewrites and routes in WordPress with this dead-simple plugin

0.9.2(1y ago)2072.5M—4.8%42[1 PRs](https://github.com/Upstatement/routes/pulls)6MITPHPPHP &gt;=7.3CI failing

Since Feb 16Pushed 2mo ago29 watchersCompare

[ Source](https://github.com/Upstatement/routes)[ Packagist](https://packagist.org/packages/upstatement/routes)[ Docs](https://www.upstatement.com)[ RSS](/packages/upstatement-routes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (6)

Routes
======

[](#routes)

Simple routing for WordPress. Designed for usage with [Timber](https://github.com/timber/timber)

[![Build Status](https://camo.githubusercontent.com/4d828366384605ee57f4bcaeda5309eb25a206c52709d157c635f613d3c53701/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f557073746174656d656e742f726f757465732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Upstatement/routes)[![Coverage Status](https://camo.githubusercontent.com/267b76e0c34cc6a9733091c9186306f7a9a80398c92442b6d3d5053eace70f11/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f557073746174656d656e742f726f757465732e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/Upstatement/routes?branch=master)![Packagist Downloads](https://camo.githubusercontent.com/5be2ed62ff8b1341079d4e9d16c713bd0f0ab912f9b0249e56003e144ef54cf5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f557073746174656d656e742f726f757465732e7376673f7374796c653d666c61742d737175617265)

### Basic Usage

[](#basic-usage)

```
/* functions.php */
Routes::map('myfoo/bar', 'my_callback_function');
Routes::map('my-events/:event', function($params) {
    $event_slug = $params['event'];
    $event = new ECP_Event($event_slug);
    $query = new WPQuery(); //if you want to send a custom query to the page's main loop
    Routes::load('single.php', array('event' => $event), $query, 200);
});
```

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

[](#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)

```
