wordpress默认加载jQuery吗?

Shr*_*aik 9 wordpress jquery

jQuery(document).ready(function($){
   alert("Hi");
});
Run Code Online (Sandbox Code Playgroud)

我想将上面写的jQuery脚本添加到body部分的WordPress站点,现在我的问题是WordPress默认是否加载jQuery库还是我需要<?php wp_enqueue_script('jquery'); ?>在脚本上面添加?

我们通常<?php wp_enqueue_script('jquery'); ?> 在开发wordpress插件时添加,但是在wordpress中手动添加jQuery脚本时需要相同的排队脚本?(我不打算创建WP插件,只是想在WordPress网站中添加jQuery代码)

Shr*_*aik 8

经过一些研究得到了我自己的问题的答案.虽然WordPress带有内置的jQuery,它默认不加载jQuery库,我们需要添加wp_enqueue_script('jquery');functions.php


ram*_*ram 0

在wp_enqueue_script到 .php 文件之前,您还需要使用wp_register_script()源路径常量位置来注册 .js (JQuery) 文件。