Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向wordpress添加easytabs jquery插件_Jquery_Wordpress - Fatal编程技术网

向wordpress添加easytabs jquery插件

向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

我想在“212儿童”主题中添加一点 我知道有一种“正确的方法”可以使用 wp_enqueue_脚本并在child-themes functions.php中添加操作

是否有人能提供添加此特定插件的分步指南,以便我分析并从中学习。

来源:

添加到functions.php

/** 
 *  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();
});