Custom templates of Posts Grid widget

In order to add your custom template of post view in the Grid widget you should use action mp_library and add template to $template[‘list’] property. Example of code:


function extendPostGridTemplate($motopressCELibrary) {
// get Post Grid from the library
$postGridObj = &$motopressCELibrary->getObject(MPCEShortcode::PREFIX . 'posts_grid');
if ($postGridObj) {
$template = &$postGridObj->getParameter('template');
// add custom template to the list
$template['list']['themes/twentythirteen/template.php'] = __('Template name', 'domain');
}
}
add_action('mp_library', 'extendPostGridTemplate', 11, 1);

The examples of existing templates can be found on /wp-content/plugins/motopress-content-editor/includes/ce/shortcodes/post_grid/templates folder.

After you add custom template it will be available at Post Grid settings panel

post-grid.jpg

Leave a Reply

Your email address will not be published. Required fields are marked *