我购买的wordpress主题的默认CSS文件中包含一些jQuery UI样式。问题是我有一个使用jQuery UI的插件,主题的默认CSS使插件损坏。我希望默认的jquery UI CSS文件覆盖包含在主题CSS文件中的UI样式
我看到一些人提到使用排队在页面底部加载jQuery CSS,但我不知道如何做到这一点。谢谢
用特定页面上的其他CSS覆盖主题样式
2 个回复
SO网友:Brad Dalton
您希望插件样式表有条件地覆盖主题样式表(在一个页面上)。
有条件地退出特定页面的主题样式表。
add_action( \'wp_enqueue_scripts\', \'remove_default_stylesheet\', 25 );
function remove_default_stylesheet() {
if ( is_page( page id or slug) ) {
wp_dequeue_style( \'original-enqueue-stylesheet-handle\' );
wp_deregister_style( \'original-register-stylesheet-handle\' );
wp_register_style( \'new-style\', plugins_url(\'stylesheet.css\', __FILE__) );
wp_enqueue_style( \'new-style\' );
}
}
SO网友:NW Tech
您可以在页脚中尝试以下操作:
<?php
function my_scripts_method() {
wp_enqueue_script(\'<script name>\',\'<script source>\');
}
add_action(\'wp_enqueue_scripts\', \'my_scripts_method\'); // For use on the Front end (ie. Theme)
?>
在哪里<script>
是脚本的名称,并且<script source>
它位于WP安装中的位置。如果这没有帮助,那么WP Codex页面上的其他一些编码可能会有所帮助,wp_enqueue_script
结束