I’m using the Themosis framework for WordPress and am trying to figure out how to use the template routing.
I’m basing this off of the routing docs
The template slug is set in the app/config/templates-config.php:
return array(
/*
* Edit this file in order to configure your page
* templates.
*
* Simply define a template slug.
*/
'custom-template'
);
Then I set the following in the routes.php:
Route::get('template', array('custom-template', function(){
return 'This will handle the custom-template slug...';
}));
But that just gets me a 404 error when I go to domain.dev/custom-template. Not sure how to make it work so that I can set up a custom template.
The templates defined inside the
templates.config.php
file are WordPress page templates. This means that you have to create a page, from WordPress admin, and assign yourcustom-template
to that page.So if you create a page with a title of
About Us
, the page URI isabout-us
. Assign thecustom-template
to your page from theTemplates
metabox (or Themosis Templates depending on your version) and visit the address at “http://yourdomain.com/about-us/” => This triggers the template route you defined.So this route is called for all pages that have the
custom-template
assigned to them. The template slugs won’t create any URI segments.