Welcome to OGeek Q&A 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 Reply

0 votes
by (71.8m points)

sorry , i totally forgot about the wp_head():

wp_head() loads all the scripts needed without the header


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...