Home API td_api_single_template::add

td_api_single_template::add

Available on: Newsmag V1.8+, Newspaper V5+
This api call is used to add a new single template style to the theme.

Usage:

<?php td_api_single_template::add( $id, $params_array ) ?>

Parameters:

$id (string) (required)

  • the single template id – the id has to be different from the ones used on the other single templates registered in theme

$params_array (array) (required)

  • an array which contains the parameters of the single template
Key name
Type
Description
file string the path of the single template file
text string the name of the single template style
img string the single template style icon, appears near the style name on post editing section
show_featured_image_on_all_pages boolean force featured image display on all pages
bg_disable_background boolean disable the featured image
bg_box_layout_config string auto | td-boxed-layout | td-full-layout
bg_use_featured_image_as_background boolean uses the featured image as a background

Examples:

In the following example we’ll add Single Template 77 , you can see how the code looks on plugin, you have to modify the file path to match with the plugin current folder, we use the variables which were introduced in the Plugin Method section, ex:

td_api_single_template::add('single_template_77',
    array(
        'file' => $this->plugin_path . '/single_template_77.php',
        'text' => 'Single template 77',
        'img' => $this->plugin_url . '/images/panel/single_templates/single_template_77.png',
        'show_featured_image_on_all_pages' => false
    )
);