admin管理员组文章数量:1410706
I'm using the plugin 'Ninja From' and I'm trying to stop it from loading a CSS file in the header.
The CSS file:
<link rel='stylesheet' id='nf-display-css' href='.css?ver=4.7.1' type='text/css' media='all' />
My code:
function remove_css_ninja_form(){
wp_dequeue_style('nf-display-css');
wp_deregister_style('nf-display-css');
}
add_action( 'wp_enqueue_scripts', 'remove_css_ninja_form', 99999 );
add_action( 'wp_print_styles', 'remove_css_ninja_form', 99999 );
add_action( 'wp_head', 'remove_css_ninja_form', 9999 );
It is not working.
I'm using the plugin 'Ninja From' and I'm trying to stop it from loading a CSS file in the header.
The CSS file:
<link rel='stylesheet' id='nf-display-css' href='http://example/wp-content/plugins/ninja-forms/assets/css/display-structure.css?ver=4.7.1' type='text/css' media='all' />
My code:
function remove_css_ninja_form(){
wp_dequeue_style('nf-display-css');
wp_deregister_style('nf-display-css');
}
add_action( 'wp_enqueue_scripts', 'remove_css_ninja_form', 99999 );
add_action( 'wp_print_styles', 'remove_css_ninja_form', 99999 );
add_action( 'wp_head', 'remove_css_ninja_form', 9999 );
It is not working.
Share Improve this question asked Jan 15, 2017 at 20:33 RexRex 1 1- sorry for the typo. – Rex Commented Jan 15, 2017 at 20:43
3 Answers
Reset to default 0Extract the ninja form plugin's files to a folder, and use a text editor such as Notepad++ to search within the files of the plugin and find either one of these phrases:
`wp_enqueue_style` OR `css_ninja_form`
You will end up with at least 1 result, which will be similar to :
add_action( 'wp_enqueue_scripts', 'css_ninja_form', xyz );
Which xyz is the priority the author of the plugin used to enqueue it. Now, you can directly remove the line from the result page (not recommended) or you can use the xyz priority to dequeue the script in your function.php.
You need to dequeue the style in nf_display_enqueue_scripts
like this :
add_action('nf_display_enqueue_scripts', function () {
wp_dequeue_style('nf-font-awesome');
wp_dequeue_style('nf-display');
});
In WordPress priority $arg
, Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
So in your functions file, I'd suggest you use:
add_action( 'wp_head', 'remove_css_ninja_form', 0 );
本文标签: wp enqueue styleStooping a css file from loading in the header
版权声明:本文标题:wp enqueue style - Stooping a css file from loading in the header 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744842732a2628021.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论