我正在开发一个 wordpress 插件,我需要在我的插件上添加 Bootstrap ,所以我如何包含那个 css、js 文件。
我做了类似下面的事情,但它不起作用
<?php
if( is_admin() ){
wp_enqueue_script('admin_js_bootstrap',$plugin_url.'admin/js/bootstrap.min.js',false,'3.3.7',false);
wp_enqueue_style('admin_css_bootstrap', $plugin_url.'admin/css/bootstrap.min.css',true,'3.3.7','all');
} ?>
最佳答案
你是否为此使用了正确的 Action Hook ?
<?php
function my_plugin_scripts() {
if( is_admin() ){
wp_enqueue_script('admin_js_bootstrap',$plugin_url.'admin/js/bootstrap.min.js',false,'3.3.7',false);
wp_enqueue_style('admin_css_bootstrap', $plugin_url.'admin/css/bootstrap.min.css',true,'3.3.7','all');
}
}
add_action( 'wp_enqueue_scripts', 'my_plugin_scripts' );
?>
并检查路径是否正确。使用浏览器的开发人员工具检查错误。
关于jquery - 在 wordpress 插件上包含 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40212689/