JavaScript
登録とエンキュー
// Use the wp_enqueue_scripts function for registering and enqueueing scripts on the front end.
add_action( 'wp_enqueue_scripts', 'register_and_enqueue_a_script' );
function register_and_enqueue_a_script() {
// Register a script with a handle of `my-script`
// + that lives inside the theme folder,
// + which has a dependency on jQuery,
// + where the UNIX timestamp of the last file change gets used as version number
// to prevent hardcore caching in browsers - helps with updates and during dev
// + which gets loaded in the footer
wp_register_script(
'my-script',
get_template_directory_uri().'/js/functions.js',
array( 'jquery' ),
filemtime( get_template_directory().'/js/functions.js',
true
);
// Enqueue the script.
wp_enqueue_script( 'my-script' );
}ローカライズ
登録解除 / キューの解除
AJAX
WP AJAX のJavaScriptサイド
クリック時のAJAX
シングルのAJAXリクエストへの複数コールバック
コールバックの連鎖
Last updated