• 0

DMS 2 How to load an external css-stylesheet from the child-theme directory after the main style.css using functions.php?


Question

Posted · Report post

I use codekit when developing sites because it's a lot better for handling Less with auto-refresh, bug reports, ability to use a decent text-editor.
So basically I'm overriding the less from the main style.css and combine them together later when work is done.

 

Here is the code in my functions.php

 

function high_priority_style() {
  Wp_enqueue_style('important', get_stylesheet_directory_uri() . '/wp-pohja-codekit/codekit.css');
}
add_action('wp_enqueue_scripts', 'high_priority_style', '999');

Still it's loading right before the main style.css

How can I load an external .css after the main style.css using functions.php?

Thanks!

Share this post


Link to post
Share on other sites

11 answers to this question

  • 0

Posted · Report post

try this

 

https://gist.github.com/Pross/c019166586e40b19a769

1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi,

 

I remember replying to a topic you wrote on this subject already - http://forum.pagelines.com/topic/32753-how-should-i-proceed-if-i-want-to-covnert-less-css-by-myself-ie-with-codekit/?hl=codekit

 

Not sure why you mention bug reports, bug reports for what and why you're using Codekit to do something that DMS already does for you ?

 

The best code editor our there is SubLime Text, some may argue for TextMate, Atom.io or elites will say Vim.

 

There are already live preview browser plugins or applications already and I am positive this can be achieved with SubLime Text too. There are also Lint packages that you can install which will inform you if you have made any errors in your code.

 

So I really don't see the benefit of using CodeKit, DMS compiles it already for you. Especially, as the built in editor already provides Live Preview.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Maybe I'm missing something, no need to argue :)
I'd still like to know how can I achieve loading an external stylesheet after the main style.css.

Thanks!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

999 is the lowest possible priority 1 is highest.

Share this post


Link to post
Share on other sites
  • 0

Posted (edited) · Report post

Danny

I made a quick video where I try to explain my situation better: 

https://www.youtube.com/watch?v=ty64wCn7OLw


The custom Less form in DMS front end:
- no auto-complete

- no snippets

- no version control

- no cmd+tabbing to go between text editor and browser

- its a small space if there is lots of less

- etc

+ live preview is nice! 

So even though I think this is a good design and totally respect it, it just won't cut it for me if I write more than a few lines. So this wont's do.

 

Child-themes style.less -file and refreshing
- slooooooooow
- Needs to refresh and deal with cached Less-files so changes won't show every time

 

Codekit:
+ fast
+ does not need even refreshing because of css-injection

+ can open the site in mobile devices and see changes change there also without refreshing

+ If I have bugs, it tells on what line they're on etcetc

- one more http-request because of another stylesheet but I can combine them later or not worry about it


So for these reasons I need to get my own .css -file in the head after the main style.css

Thanks!

Edited by ketri

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Danny
Could I please get a little bit of help here =) 
I still cannot get the .css -file to load after the main style.css. 
I tried using different header hooks but for some reason the .css file ends up outside the <head>...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

this works:

 

https://gist.github.com/Pross/c019166586e40b19a769

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks for your reply Simon_P

Unfortunately it's still adding the stylesheet just before the main DMS style.css. I think I also tried a similar solution I found from stackoverflow. 

https://www.dropbox.com/s/m79bm8k41h08ud7/Screenshot%202014-05-22%2014.58.37.png

I wonder why is that? I'd assume that someone who knows DMS inside out would know how the main stylesheet gets loaded and how can we load something after it.

Thanks!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

change 11 to something higher.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I tried 100, 999, 9999 but unfortunately it's always just before the main style.css

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Yes!
Thank you very much for taking the time to help me with this one Simon_P! :) 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now