Routing in Cuisine can have two meanings:
On this page we’ll be looking into routing to a URL. If you’re looking to route your post type to a certain template-file check out the page on templating.
The Route-class is available through Cuisine’s Wrapper System, so you can start using it by adding
to the top of your php-document.
Routing post types to urls is done by using the WordPress Rewrite system. Which is, again, needlessly complex. Cuisine really simplifies this. Routing always works with two url-routes for a post type. One for the archive or overview and one for the single post type page.
So, following our example of the project-post type, we’ll create a route for our post type project. We’ll want the overview page to be named /our-work and an single project can route to /project/project-name.
Route::url( 'project', 'our-work', 'project' );
That’s it. Here’s the breakdown for the example above:
The parameters passed down to the make-function are, in order of appearence:
post type slug The slug of the post-type we’re tying this taxonomy to. This can be an array of post-type slugs as well.
overview slug The url we want to use for our overview or archive page.
singular slug The prefix to the url we want to use for our singular pages.