0

in my main plugin page i check if a certain page is visited if so, i load a certain template. in the following way:

add_filter( 'template_include', array($this, 'includeTemplate'), 99 );
public function includeTemplate($template){ 
    global $wp_query;
    if(is_page() && $wp_query->query['pagename'] == 'my_page_name'){
       include(plugin_dir_path( __FILE__ ).'templates/my_page_name.php');
       die;
    }
    return $template;
}

my question is how can i load all the queue scripts and styles to this template without using the_header()

I've tried :

global $wp_scripts;
foreach( $wp_scripts->queue as $handle ) :
    echo $handle . ' | ';
endforeach;

The above echoed admin-bar

Thanks.

2 Answers 2

1

the_header() does not even seem to be native WP function?

Technically getting header isn't what really causes styles and scripts to load, it's wp_head() call that should be made there (and wp_footer() call in footer). So they are likely what you should be using.

If you do need something lower level you might want to look at:

1
  • well neither of the tree worked.. wp_head() does what it suppose to but for some reason it adds 2 hidden divs which i cant seem to find where the originate from
    – Neta Meta
    Commented Feb 11, 2014 at 21:00
0

Untested, but you should be able to run the wp_enqueue_scripts filter yourself.

do_action('wp_enqueue_scripts');

That should give you the best chance of loading scripts and styles without also loading other things that might be hooked into (rightly or wrongly) [wp_head'][2], [wp_footer][3], or thewp_print_styles` hook, which seems to be subject to abuse.

You may also want

do_action('wp_print_head_scripts');

and

do_action('wp_print_footer_scripts');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.