How to force wp_enqueue_style to display CSS at the very bottom of the head tag to override all CSS rules?

人盡茶涼 提交于 2019-12-05 05:16:48

Hey. There's an argument called $deps for wp_enqueue_style, you should give it a try. You might be able to mention that your stylesheet depends on all the rest, thus putting it below the others. Other than that, you can also go ahead with !important. More info on dependencies: http://codex.wordpress.org/Function_Reference/wp_enqueue_style

ssaltman

I know this is ancient, but here's some actual code, cut and pasted from my site. This is in the functions.php file of my child theme:

 add_action('init', 'add_custom_styles', 99);
 function add_custom_styles() {
     wp_enqueue_style(
         'custom-styles',
         get_stylesheet_directory_uri() .'/custom.css',
         array('storefront-style', 'wc-bundle-style','storefront-child-style')
    );
 }

The 'custom-styles' is simply a file titled "custom.css" in the child theme directory which contains all my custom styles I want to be loaded last.

In addition, to find the handles of the stylesheets that you want to be above your custom.css stylesheet, use the technique outlined here:

http://crunchify.com/how-to-print-all-loaded-java-scripts-and-css-stylesheets-handle-for-your-wordpress-blog/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!