我已经在我的wordpress主题管理面板中设置了一个尾部气泡信息弹出窗口,当我将代码放入主题-options.php文件中时,它工作得很好。我像它应该的那样将它包含在functions.php中,并且它被加载到管理面板中:
// De scripts enkel voor admin
if (is_admin()){
wp_register_script( 'bubble', NHP_OPTIONS_URL.'js/bubble.js');
wp_enqueue_script('bubble'
如何确定是否调用了Wordpress主题文件?例如,每次加载archive.php时,我都希望有条件地在页脚中添加一个js文件。
我目前在functions.php中使用类似这样的东西来加载全局js。如何根据调用的Wordpress文件调整以加载额外的js?
//Use Google CDN to load jQuery
function use_google_jquery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
w
在此之前,要将jQuery包含在Wordpress中,您必须这样做:
wp_enqueue_script('jquery');
但是,作为一种确保jquery尚未加载的方法,有些人会这样做:
function sp_load_jquery() {
// only use this method is we're not in wp-admin
if ( ! is_admin() ) {
// deregister the original version of jQuery
wp_deregister_script(