Please read the WordPress docs for templates.
Each WordPress template will use one of the templates defined in gotoAndPlay/Templates
folder.
It will call render function that is inherited from the parent.
When creating a template usually you need to create at least two files.
template-[name].php
is the file for WordPress.gotoAndPlay/Template/[name].php
template class which will be used to pass all data to twig.In this example we create a simple playground template.
<?php
/*
* Template name: Playground
*/
gotoAndPlay\Templates\Playground::render();
And also the corresponding class with a simple get method.
<?php
namespace gotoAndPlay\Templates;
use gotoAndCore\Fields\Relationship;
use gotoAndPlay\Models\Page;
class Playground extends Page {
/* is used to determine which view should be rendered from styleguide */
protected function getView() {
return '@view-playground';
}
public static function getFields() {
return [
'players' => new Relationship([
'post_type' => 'player',
]),
];
}
}