Use Page Template feature

Alessandro Fazzi edited this page Apr 13, 2017 · 3 revisions

Make a folder in theme's root named page-templates and create a consistently named php file

mkdir page-templates
touch page-templates/static.php

and write it as follow

* Template Name: Static

include(get_template_directory() . '/index.php');

Write down an ad-hoc template, e.g. theme/views/layout/static.html.pug

doctype html
  head= render_partial("layouts/head")
    .page-wrapper This is my static page template wl_yield() render_partial("layouts/footer")
    // jQuery and application.js is loaded by default with wp_footer() function. See config/initializers/default_hooks.php for details
    - wp_footer()

then in your router you can control as you wish

/* ./index.php */

 * Making sure Wordless plugin is enabled

if (!class_exists("Wordless")) {
  echo "This theme requires the <a href=''>Wordless plugin</a> in order to work. Please, install it now!";

 * In this page, you need to setup Wordless routing: you first
 * determine the type of the page using WordPress conditional tags,
 * and then delegate the rendering to some particular view using
 * the `render_view()` helper.
 * To specify a layout other than the default one, please pass it as
 * the second parameter to the `render_view()` method.
 * For a list of conditional tags, please see here:

if (is_page_template("page-templates/static.php")){
    /* Render something here, e.g: */
    render_view('posts/page', 'static');
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.