PHP code example of stellarwp / templates

1. Go to this page and download the library: Download stellarwp/templates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stellarwp / templates example snippets


use Boomshakalaka\StellarWP\Templates\Config;

add_action( 'plugins_loaded', function() {
	Config::set_hook_prefix( 'boom-shakalaka' );
	Config::set_path( PATH_TO_YOUR_PROJECT_ROOT );
} );

use Boomshakalaka\StellarWP\Templates\Template;

class My_Custom_Template extends Template {

	/**
	 * Defines the base path for the templates.
	 *
	 * @since 1.0.0
	 */
	protected array $template_base_path = [ PATH_TO_YOUR_PROJECT_ROOT ];

}

$template = new My_Custom_Template();

// Set the folder within your plugin where templates are stored.
$template->set_template_folder( 'src/views/products' );
// Should users be able to override templates in their theme?
$template->set_template_folder_lookup( true );

../themes/child/boom-shakalaka/products/template-file

../themes/parent/boom-shakalaka/products/template-file