0

http://os.alfajango.com/easytabs/を TwentyTwelve 子テーマに追加したいのですが、wp_enqueue_script を使用して jquery プラグインを Wordpress に追加し、子テーマ functions.php にアクションを追加する「正しい方法」があることを理解しています。

誰かがこの特定のプラグインを追加するためのステップバイステップのガイドを提供してくれるので、分析してそこから学ぶことができます.

4

2 に答える 2

0

と を使用する必要が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>
于 2013-03-09T16:00:59.980 に答える
-1

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();
于 2013-03-09T15:22:21.423 に答える