PHPackages                             devaly/wordpress-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. devaly/wordpress-routes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

devaly/wordpress-routes
=======================

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

v0.0.8(7y ago)101.3k1[1 issues](https://github.com/DevAly/wordpress-routes/issues)[4 PRs](https://github.com/DevAly/wordpress-routes/pulls)GPL-3.0-or-laterPHPPHP &gt;=5.6.0

Since Mar 23Pushed 4y agoCompare

[ Source](https://github.com/DevAly/wordpress-routes)[ Packagist](https://packagist.org/packages/devaly/wordpress-routes)[ Docs](https://github.com/med-amin)[ RSS](/packages/devaly-wordpress-routes/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (8)Dependencies (5)Versions (15)Used By (0)

Routes
======

[](#routes)

Simple routing for WordPress.

This package is a re-organised and maintained version of [Upstatement/routes](https://github.com/Upstatement/routes)

[![Build Status](https://camo.githubusercontent.com/34c0f947362d95bcd1b2b1b5ed0988535d5d2515dc7c1f51c2ffdb8891b6046e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f446576416c792f776f726470726573732d726f757465732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/DevAly/wordpress-routes)[![Coverage Status](https://camo.githubusercontent.com/cc72c4e4638ee911d0051de9717bf07cc33ecc304d14669b8905f0c9c5567284/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f446576416c792f776f726470726573732d726f757465732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/DevAly/wordpress-routes?branch=master)[![Coverage Status](https://camo.githubusercontent.com/e8336c97df33a6811b321cb791ae38aca8574400d192691f75d8daa062359b79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f646576616c792f776f726470726573732d726f757465732e737667)](https://github.com/DevAly/wordpress-routes)[![GitHub](https://camo.githubusercontent.com/a69e2cca9e95e1e3f270a310a01452d66546e6b301b3254c2fe1f1498d9a3edd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f446576416c792f776f726470726573732d726f757465732e737667)](https://camo.githubusercontent.com/a69e2cca9e95e1e3f270a310a01452d66546e6b301b3254c2fe1f1498d9a3edd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f446576416c792f776f726470726573732d726f757465732e737667)[![Total Downloads](https://camo.githubusercontent.com/fa1362bc8cdf9a1f4104650f791f64695e22533659f6cbd5051382a738b556d1/68747470733a2f2f706f7365722e707567782e6f72672f646576616c792f776f726470726573732d726f757465732f642f746f74616c2e737667)](https://packagist.org/packages/devaly/wordpress-routes)

Installation
============

[](#installation)

Require WP Routes with composer

```
$ composer require devaly/wordpress-routes

```

OR
==

[](#or)

Download the WP Routes from [Releases](https://github.com/DevAly/wordpress-routes/releases) assets wordpress-routes.zip and install as wordpress plugin

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

```
