Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Upstatement/routes
Simple routing for WordPress
https://github.com/Upstatement/routes
Last synced: 7 days ago
JSON representation
Simple routing for WordPress
- Host: GitHub
- URL: https://github.com/Upstatement/routes
- Owner: Upstatement
- Created: 2014-10-30T03:15:53.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T15:26:01.000Z (almost 2 years ago)
- Last Synced: 2024-09-08T02:07:53.829Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 69.3 KB
- Stars: 187
- Watchers: 33
- Forks: 38
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Routes
Simple routing for WordPress. Designed for usage with [Timber](https://github.com/timber/timber)[![Build Status](https://img.shields.io/travis/Upstatement/routes/master.svg?style=flat-square)](https://travis-ci.org/Upstatement/routes)
[![Coverage Status](https://img.shields.io/coveralls/Upstatement/routes.svg?style=flat-square)](https://coveralls.io/r/Upstatement/routes?branch=master)
[![Packagist Downloads](https://img.shields.io/packagist/dt/Upstatement/routes.svg?style=flat-square)]()### Basic Usage
```php
/* 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
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)```php
'foo', 'bar' => 'I dont even know');
Routes::load('archive.php', $params, $query);
});
```## map
`Routes::map($pattern, $callback)`
### Usage
A `functions.php` where I want to display custom paginated content:
```php