• Resolved bartezzini

    (@bartezzini)


    I solved the problem to have 1 template added to the default one. But now I got to add a second template to plugin and i tried

    function myRowTemplates( templates ) {
    	templates.push( {
    		name: '1-1',
    		title: '1 Columns (1:1)',
    		icon: 'editor-justify',
    		templateLock: 'all',
    		template: [
    			[
    				'wp-bootstrap-blocks/column',
    				{
    					sizeXs: 1,
    					sizeMd: 4,
    				},
    			],
    		],
    	} );
    	templates.push( {
    		name: '1-2',
    		title: '2 Columns (1:2)',
    		icon: 'editor-justify',
    		templateLock: 'all',
    		template: [
    			[
    				'wp-bootstrap-blocks/column',
    				{
    					sizeXs: 12,
    					sizeMd: 10,
    				},
    			],
    			[
    				'wp-bootstrap-blocks/column',
    				{
    					sizeXs: 12,
    					sizeMd: 2,
    				},
    			],
    		],
    	} );
    	return templates;
    }
    wp.hooks.addFilter(
    	'wpBootstrapBlocks.row.templates',
    	'myplugin/wp-bootstrap-blocks/row/templates',
    	myRowTemplates
    );

    but it didn’t work. Am I missing something to query?

    • This topic was modified 3 years, 11 months ago by bartezzini.
    • This topic was modified 3 years, 11 months ago by bartezzini.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor tschortsch

    (@tschortsch)

    Hi @bartezzini. It looks like you’re trying to define a template with the same name as a template which already exists by default name: '1-2'. Removing the already existing template from the array or choosing another name for the new template should solve your issue.

    Thread Starter bartezzini

    (@bartezzini)

    Thank you a lot @tschortsch.
    Works perfectly: you saved my layout ??
    (your plugin is amazing: the dream of every plugin user)

    Plugin Contributor tschortsch

    (@tschortsch)

    Happy that it helped. We should maybe mention something about the uniqueness of the name attribute in the readme of the plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘2 Templates?’ is closed to new replies.