[英]I need to change order of scripts in footer of my wordpress site so my custom main.js file loads last of all scripts
這就是我在functions.php
調用我的自定義腳本的子主題:
<?php
/*Functions file for child theme*/
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_stylesheet_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
function mychildtheme_setup() {
show_admin_bar(false);
wp_register_script( 'main', get_stylesheet_directory_uri() . '/js/main.js', array('jquery'), false, true);
wp_enqueue_script( 'main' );
}
add_action('after_setup_theme', 'mychildtheme_setup');
add_action( 'wp_enqueue_scripts', 'mychildtheme_setup', 10000 );
?>
但是,當我查看源代碼時,我發現main.js
在contact-form.js
之前加載,並且我希望main.js
腳本在那之后加載。
如何更改順序,以便腳本加載所有腳本中的最后一個?
還需要答案嗎?
此處已回答了類似的問題: https : //wordpress.stackexchange.com/questions/114473/wp-enqueue-script-how-to-change-loading-order-of-scripts 。
關鍵字是$deps
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.