Home>Support>getting widget assets in custom query

getting widget assets in custom query

By kralla, 10 years ago. Last reply by kralla, 10 years ago.
Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

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. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 10 years, 4 months ago kralla

    found 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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More