That could be possible if you are running this code before NextGEN has initialized and loaded; how / when are you invoking that PHP?
The problem is that nextgen is seeing the page as an admin page. So, when I have an array of posts nextgen cannot do the function do_shortcode().
You can make NextGEN load its display logic in the WP-Admin by applying __return_true to the filter `ngg_load_frontend_logic’. It passes a second parameter of the module name if you wish to only enable certain display types.
I added the filter as you suggested:
public function wmc_load_frontend_logic($p1, $p2) {
__return_true();
}
I would think this would enable the shortcode the tag but it is stillnot there. In an other plugin triggerred by a post_row I do see the shortcode tag: “ngg”.
The folowing series of command lead to some action. I’m getting the default template:
$utl = C_Component_Registry::get_instance();
$utl->add_utility( 'I_Display_Type_Controller', 'C_Display_Type_Controller');
$utl->add_utility( 'I_Displayed_Gallery_Renderer', 'C_Displayed_Gallery_Renderer' );
$utl->add_adapter('I_MVC_View', 'A_Gallery_Display_View');
$utl->add_adapter('I_MVC_View', 'A_Displayed_Gallery_Trigger_Element');
$utl->add_adapter('I_Display_Type_Controller',
'A_Displayed_Gallery_Trigger_Resources');
$renderer = C_Displayed_Gallery_Renderer::get_instance();
$reply = $renderer->display_images(array('src' => 'tags', 'ids' => array('Y2021 M1 D10'), 'display' => 'basic_thumbnail' ));
$reply than contains:
(string) <h1>Default Gallery Type Template</h1>
<p>
This is the default gallery type template, located in:<br/>
<b>C:\xampp\htdocs\wp\wp-content\plugins\nextgen-gallery\products\photocrati_nextgen\modules\nextgen_gallery_display\templates\index.php</b>.
</p>
<p>
If you're seeing this, it's because the gallery type you selected has not
provided a template of it's own.
</p>
So all in all not yet an success
-
This reply was modified 5 years, 2 months ago by
vandestouwe.
@vandestouwe What you have there is a method that is executing __return_true but that doesn’t actually have any effect, your wmc_load_frontend_logic() is actually returning null.
Try using add_filter('ngg_load_frontend_logic', '__return_true'); — you could also use return true; in your existing method.
Thanks @benjaminowens this works fine now.