簡體   English   中英

WordPress的jQuery手風琴菜單

[英]Jquery accordion menu in wordpress

您能幫我,我寫的用於jquery手風琴的javascript代碼在哪里寫的正確位置,我應該將其放置到file.js並在functions.php,wp_register,wp_enqueue,add_item中通過函數調用嗎? 我是這個系統的新手。 非常感謝您的幫助

要將自定義javascript添加到您的網站,您應該查看wp_enqueue_script函數。

您可以在主題的functions.php中或在創建的插件文件中使用它,具體取決於您是否希望它成為主題的一部分。

以下示例來自上面鏈接的頁面,還介紹了使CSS排隊的等效功能:

/**
* Proper way to enqueue scripts and styles
*/
function theme_name_scripts() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM