getting widget assets in custom query
i need to create a theme, where on the main site multiple specific pages that contain page builder content are shown. the problem is, that the assets needed for the widgets aren’t enqueued this way.
the query looks similar to this:
$args = array(
'meta_key' => '_display_as_modal',
'meta_value' => 'no'
);
$pages = get_pages($args);
foreach ( $pages as $page ) {
echo apply_filters( 'the_content', $page->post_content );
}the pages show up correctly if they are accessed on their own via their uri. does anybody know how to do this and load the required assets correctly?
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
1found the solution myself. here you go:
$args = array( 'meta_key' => '_display_as_modal', 'meta_value' => 'no' ); $pages = get_pages($args); foreach ( $pages as $page ) { $instances = get_post_meta($page->ID, 'panels_data'); foreach($instances as $i) { if (array_key_exists('widgets', $i)) { foreach($i['widgets'] as $widget) { $w = new $widget['panels_info']['class']; $args = array( 'before_title' => '', 'after_title' => '', 'before_widget' => '<div class="widget %s">', 'after_widget' => '</div>' ); $w->widget($args, $widget); } } } }Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.