admin管理员组文章数量:1302929
I'm trying to create a slider shortcode with Slick Slider and for some reason it does not work in the admin page in the page builder and I'm getting this error:
I already enqueue it in my functions.php
like so:
function custom_scripts() {
wp_enqueue_style( 'slick', '//cdn.jsdelivr/npm/[email protected]/slick/slick.css');
wp_enqueue_script( 'slick', '//cdn.jsdelivr/npm/[email protected]/slick/slick.min.js',array('jquery'), '1.0', true);
}
add_action( 'admin_enqueue_scripts', 'custom_scripts' );
And added
var $ = jQuery.noConflict();
In my shortcode function but still doesn't work, though the enqueued style and script is visible on the page already.
Note: It works fine in the front end. I just wanted to show it in the admin page so my client can see it while updating the page with page builder.
I'm trying to create a slider shortcode with Slick Slider and for some reason it does not work in the admin page in the page builder and I'm getting this error:
I already enqueue it in my functions.php
like so:
function custom_scripts() {
wp_enqueue_style( 'slick', '//cdn.jsdelivr/npm/[email protected]/slick/slick.css');
wp_enqueue_script( 'slick', '//cdn.jsdelivr/npm/[email protected]/slick/slick.min.js',array('jquery'), '1.0', true);
}
add_action( 'admin_enqueue_scripts', 'custom_scripts' );
And added
var $ = jQuery.noConflict();
In my shortcode function but still doesn't work, though the enqueued style and script is visible on the page already.
Note: It works fine in the front end. I just wanted to show it in the admin page so my client can see it while updating the page with page builder.
Share Improve this question edited Feb 28, 2021 at 11:07 leonardeveloper asked Feb 28, 2021 at 10:57 leonardeveloperleonardeveloper 1151 silver badge10 bronze badges 3 |1 Answer
Reset to default 0Could your shortcode function be running or loading before Slick.js has loaded?
Simple solution might be to load slick in the header by changing the last parameter from true to false, but this isn't really the 'correct' way as it will impact performance slightly.
If your shortcode function is in a seperate file loaded by enqueueing then add slick as a dependancy.
If it's in the HTML so loaded from a PHP file, move it to a seperate JS file, enqueue it with admin_enqueue_scripts and again add Slick as a dependency.
本文标签: shortcodewpenqueuescripts does not work on admin page
版权声明:本文标题:shortcode - wp_enqueue_scripts does not work on admin page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741716332a2394132.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
admin_enqueue_scripts
action hook. wordpress.stackexchange/questions/67476/… – nmr Commented Feb 28, 2021 at 11:07