http://os.alfajango.com/easytabs/を TwentyTwelve 子テーマに追加したいのですが、wp_enqueue_script を使用して jquery プラグインを Wordpress に追加し、子テーマ functions.php にアクションを追加する「正しい方法」があることを理解しています。
誰かがこの特定のプラグインを追加するためのステップバイステップのガイドを提供してくれるので、分析してそこから学ぶことができます.
http://os.alfajango.com/easytabs/を TwentyTwelve 子テーマに追加したいのですが、wp_enqueue_script を使用して jquery プラグインを Wordpress に追加し、子テーマ functions.php にアクションを追加する「正しい方法」があることを理解しています。
誰かがこの特定のプラグインを追加するためのステップバイステップのガイドを提供してくれるので、分析してそこから学ぶことができます.
と を使用する必要がwp_register_script
ありwp_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>
From: WordPress サポートページ
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 **/ });
add内に以下のスニペットを配置します。
$('#container-name-for-tabs').easytabs();