我必须做一个wp插件,它调用一个带有短代码的页面:
function shortcode_flexSlide(){
include ('eleve.php');
}
add_shortcode('flexSlide', 'shortcode_flexSlide');
现在我必须加载css和js链接到'eleve.php'页面
我已经尝试过以下方法:
wp_enqueue_script( 'flexSlideStyle', plugins_url( '/css/style.css', __FILE__ ));
但是看看wp root dir + /css/style.css
如果要将样式表排入队列,请使用以下语法。
wp_enqueue_style( 'myCSS', plugins_url( '/css/style.css', __FILE__ ) );
或者您可以使用以下内容:
wp_enqueue_style( 'style-name', get_stylesheet_directory_uri(). '/css/style.css' ); // for css
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); // for script, where 1.0.0 is the version
希望这可以帮助 :)