JS dosyamı eklemek için burada ipuçlarını kullanmaya çalışıyorum.
Aşağıdakileri kurduğum atahualpa temasının functions.php dosyasına koydum.
function lektor_init() {
if (true) {
wp_enqueue_script('lektor',TEMPLATEPATH.'/js/synteza.js');
}
}
add_action('init','lektor_init');
TEMPLATEPATH
zaten orada daha önce kullanılmış, bu yüzden yeni uyarladım. Ama görünmüyor.
Neyi yanlış yaptım?
TEMPLATEPATH
bir URL değil, bir dizin yoludur. get_template_directory_uri()
kullanmanız gerekecek.
function parent_theme_name_scripts() {
wp_enqueue_script( 'lektor', get_template_directory_uri() . '/js/synteza.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'parent_theme_name_scripts' );
Ailene temalar fonksiyonları dosyasını ekleyin.
Ancak, bir üst temaya komut dosyaları ekliyorsanız, bir alt tema oluşturun ve komut dosyasını get_stylesheet_directory_uri()
kullanarak alt temalar işlev dosyasına ekleyin.
add_action( 'wp_enqueue_scripts', 'child_theme_name_scripts' );
function child_theme_name_scripts() {
wp_enqueue_script( 'lektor', get_stylesheet_directory_uri() . '/js/synteza.js', array(), '1.0.0', true );
}
wp_enqueue_scripts
yerine init
NAME _ kullanın.