向wordpress添加easytabs jquery插件
我想在“212儿童”主题中添加一点 我知道有一种“正确的方法”可以使用 wp_enqueue_脚本并在child-themes functions.php中添加操作 是否有人能提供添加此特定插件的分步指南,以便我分析并从中学习。来源: 添加到functions.php向wordpress添加easytabs jquery插件,jquery,wordpress,Jquery,Wordpress,我想在“212儿童”主题中添加一点 我知道有一种“正确的方法”可以使用 wp_enqueue_脚本并在child-themes functions.php中添加操作 是否有人能提供添加此特定插件的分步指南,以便我分析并从中学习。来源: 添加到functions.php /** * if jQuery not been * added already **/ wp_enqueue_script('jquery'); /** * Register the script to Wor
/**
* if jQuery not been
* added already
**/
wp_enqueue_script('jquery');
/**
* Register the script to Wordpress
**/
wp_register_script('easytabs','js/easytabs.js');
/**
* Add the Registered script to queue.
**/
wp_enqueue_script('easytabs');
您可以通过查看
中的HTML源代码(其中调用了wp_head()
)来检查它是否工作正常
将下面的代码片段放在jQuery(document.ready)中(函数($){/**您的代码**/})代码>添加:
$('#container-name-for-tabs').easytabs();
你应该使用和。将文件添加到主题文件夹中
function include_jquery_easytabs(){
wp_enqueue_script( 'jquery');
wp_register_script( 'jq_easytabs', get_template_directory_uri() . 'PATH TO YOUR JS FILE' );
wp_enqueue_script( 'jq_easytabs' );
}
add_action( 'wp_enqueue_scripts', 'include_jquery_easytabs' );
将以下snipper添加到
标记之前的footer.php
,或添加到
标记之前的header.php
:
<script>
jQuery(document).ready(function($){
$('your-target-element').easytabs();
});
</script>
jQuery(文档).ready(函数($){
$('your-target-element').easytabs();
});