2013-03-09 52 views

回答

-1

來源:Wordpress Support Pages

添加到的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'); 

您可以檢查它是否在<head>中查看HTML源代碼(其中wp_head()被調用的)工作。

將低於jQuery(document).ready(function($){ /** Your code **/ });附加內的片段:

$('#container-name-for-tabs').easytabs(); 
0

您應該使用wp_register_scriptwp_enqueue_script。將該文件添加到您的主題文件夾。

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'); 

添加以下剪斷你的footer.php</body>標籤之前或您header.php</head>標記之前:

<script> 
jQuery(document).ready(function($){ 
    $('your-target-element').easytabs(); 
}); 
</script>