Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

php - How to load scripts without the get_header() function

I'm looking for a way to scripts that a plugin need to run without the get_header(); function

here's a backstory about what's happening

I'm working on BuddyPress plugin, specifically the template part of it. I created new template, define the file and everything is running without errors.

The template I'm working on doesn't use the get_header(); function because I don't want the header in that template to be visible.

A picture of how's the code looks like:

* This Is A BuddyPress Template [ With No Header ]

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly

<div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
        <main id="main" <?php generate_do_element_classes( 'main' ); ?>>
             * generate_before_main_content hook.
             * @since 0.1
            do_action( 'generate_before_main_content' );

            if ( generate_has_default_loop() ) {
                while ( have_posts() ) :


                    generate_do_template_part( 'page' );




Everything is good to this point: BuddyPress loads and the profile user loads.

The issue is that the members page stucks at Loading members of the community. Please wait. and every non static page is stuck.

Well this is happing because some scripts are not loading in <head> </head> but when I call the get_header(); function

all the scripts load

I tried to search about it in Stackoverflow but haven't found anything I needed and some scripts are not working and it's undefined

like the wp_print_head_scripts(); - it not printing any scripts and this method didn't work

I also tired to load it directly from the same template like

and that didn't work ether So I'm stuck here. Anybody? if I forgot something please tell me I'll appreciate that (:

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

sorry , i totally forgot about the wp_head():

wp_head() loads all the scripts needed without the header

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share