Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
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' ); ?>>
            <?php
            /**
             * generate_before_main_content hook.
             *
             * @since 0.1
             */
            do_action( 'generate_before_main_content' );

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

                    the_post();

                    generate_do_template_part( 'page' );

                endwhile;
            }

    


    get_footer();

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 OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...