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.

up vote 1 down vote accepted

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:

  • 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 Feb 11 '14 at 21:00

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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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