我试试这个:
add_action(\'admin_print_scripts\', \'custom_admin_scripts\' );
function custom_admin_scripts() {
echo \'<script type="text/javascript" src="\' . get_bloginfo(\'stylesheet_directory\') . /admin-scripts.js"></script>\';
}
但通过这种方式,它无法识别jQuery。所以我得到Uncaught ReferenceError: jQuery is not defined
.<我认为这是因为jQuery是在我的脚本之后链接的。正如我在HTML源代码中看到的:<script type="text/javascript" src="http://localhost:8080/wp-test/wp-content/themes/test/admin-scripts.js"></script>
<script type="text/javascript" src="http://localhost:8080/wp-test/wp-admin/load-scripts.php?c=1&load=jquery,utils&ver=edec3fab0cb6297ea474806db1895fa7"></script>
我怎样才能修复它?