【发布时间】:2020-01-17 01:36:01
【问题描述】:
我将 html、css、js 模板转换为 wordpress 主题。 为了让我的css正常工作,我只是在functions.php中添加了函数,但是为了让javascript加入队列它不起作用我尝试了很多修改但没有任何效果 这是我的function.php
<?php
function load_stylesheets()
{
wp_register_style('normal',get_template_directory_uri() . '/css/normalize.css', array(), 1, 'all');
wp_enqueue_style('normal');
wp_register_style('demonstration',get_template_directory_uri() . '/css/demo.css', array(), 1, 'all');
wp_enqueue_style('demonstration');
}
add_action('wp_enqueue_scripts','load_stylesheets');
function addjs()
{
wp_register_script('anime', get_template_directory_uri() . '/js/anime.min.js', array(), 1,1, 1);
wp_enqueue_script('anime');
wp_register_script('imagesload', get_template_directory_uri() . '/js/imagesloaded.pkgd.min.js', array(), 1,1, 1);
wp_enqueue_script('imagesload');
wp_register_script('main', get_template_directory_uri() . '/js/main.js', array(), 1,1, 1);
wp_enqueue_script('main');
}
【问题讨论】:
-
你也需要
add_action('wp_enqueue_scripts', 'addjs'); -
我已经这样做了,但没有任何改变,而且在很多情况下,我在其他帖子中看到他们没有这样做。
标签: javascript php wordpress templates enqueue