引导程序在我的自定义插件中不起作用
// register jquery and style on initialization
add_action('init', 'register_script');
function register_script() {
wp_register_style( 'bootstrap', plugins_url('/bootstrap/css/bootstrap.css', __FILE__));
}
// use the registered jquery and style above
add_action('wp_enqueue_scripts', 'enqueue_style');
function enqueue_style(){
wp_enqueue_style( 'bootstrap' );
}
我的文件夹的名称是离职估计器,它只有boot rap文件夹和crotovercalculator.php
我试图调用BTN类,以便在工作时尝试,但仍无法正常工作。
// register jquery and style on initialization
add_action('init', 'register_script');
function register_script() {
wp_register_style( 'bootstrap', plugins_url('/bootstrap/css/bootstrap.css', __FILE__));
}
// use the registered jquery and style above
add_action('wp_enqueue_scripts', 'enqueue_style');
function enqueue_style(){
wp_enqueue_style( 'bootstrap' );
}
my folder's name is turnover-calculator it only have the bootrap folder and turnovercalculator.php
i tried to call the btn class to try if it's working but it's still not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用正确的挂钩,
wp_register_style
和wp_enqueue_style
只能在wp_enqueue_scripts
hook hook in ofer Inside 。请使用此代码:
You have to use the right hooks,
wp_register_style
andwp_enqueue_style
can only be called insidewp_enqueue_scripts
hook.please use this code:
您可以直接在
wp_enqueue_scripts
回调之类的中直接介绍样式:
You can just enqueue the style directly inside the
wp_enqueue_scripts
callback like this: