我设法做到了这一点:
define(\'WP_USE_THEMES\', true);
require( \'../wp-load.php\' );
// Register all scripts and styles
do_action(\'wp_enqueue_scripts\');
// Execute footer hooks
do_action(\'get_footer\');
// output the js
wp_print_footer_scripts();
wp_footer();
它还输出排队的CSS文件,所以我通过创建一个helper函数对其进行了调整
function dequeue_scripts_or_styles($slug) {
wp_dequeue_style( $slug );
wp_deregister_style( $slug );
}
所以最后的代码是
define(\'WP_USE_THEMES\', true);
require( \'../wp-load.php\' );
// Register all scripts and styles
do_action(\'wp_enqueue_scripts\');
// Remove things that should not sit in the footer
dequeue_scripts_or_styles( \'wc-responsive-video-scripts\' );
dequeue_scripts_or_styles( \'sage/css\' );
// Execute footer hooks
do_action(\'get_footer\');
// output the js
wp_print_footer_scripts();
wp_footer();
?>
</body>
</html>