# blockspare/2.6.6/inc/page-templates/module.php

BlockSpare – Gutenberg Blocks, AI Content Generator &amp; Site Builder for news, magazine, blog and business sites, version 2.6.6. 36 lines.

- Page: https://pluginprobe.com/plugins/blockspare/2.6.6/code/inc/page-templates/module.php
- Raw: https://pluginprobe.com/plugins/blockspare/2.6.6/raw/inc/page-templates/module.php
- Modified: 2023-09-07T10:20:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/blockspare/2.6.6/code/inc/page-templates/module.php#L10-L20`.

```php
<?php
//Add our custom template to the admin's templates dropdown
add_filter( 'theme_page_templates', 'pluginname_template_as_option', 10, 3 );
function pluginname_template_as_option( $page_templates, $theme, $post ){

    $page_templates['canvas.php'] = 'Blockspare Canvas';
    $page_templates['full-width.php'] = 'Blockspare Full-Width';

    return $page_templates;

}

//When our custom template has been chosen then display it for the page
add_filter( 'template_include', 'pluginname_load_template', 99 );
function pluginname_load_template( $template ) {

    global $post;

    if(isset($post)){
        
        $canvas_template_slug   = 'canvas.php';
        $full_width_template_slug   = 'full-width.php';
        $page_template_slug     = get_page_template_slug( $post->ID );
    
        if( $page_template_slug == $canvas_template_slug ){
            return BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/templates/' . $canvas_template_slug;
        }
    
        if( $page_template_slug == $full_width_template_slug ){
            return BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/templates/' . $full_width_template_slug;
        }    
        
    }
    return $template;

}
```
