1

I'm trying add CSS to testimonial slider (3rd Party plugin) on my wordpress theme. But my custom CSS file loads before the plugin CSS file.

Is there a way I can make the my custom CSS load after the plugin CSS?

I don't want to make any changes to the Plugin code.

Edit: I noticed that the plugin is using "wp_print_styles" to load it's css file.

4
  • how do you add your plugin css and custom css file? Commented Sep 22, 2015 at 11:42
  • please paste your code to add custom css and plugin css Commented Sep 22, 2015 at 11:46
  • while enqueue script you can set up priority right? add_action('wp_enqueue_scripts','testfunction',10); change any value from 1 to any value lower the number higher the priority Commented Sep 22, 2015 at 11:48
  • I'm using a 3rd party plugin. I've not build the plugin. I use wp_enqueue_style() to load my css file. Commented Sep 22, 2015 at 12:01

1 Answer 1

1

You'll need to update your plugin code to do this the "proper way" I believe.

Since you need it to load last I would take the common path of utilizing the wp_enqueue_scripts hook/function to set a low priority for it being processed. This way you can guarantee that the HTML remains valid and that you are loading your styles and scripts after all the default ones within WordPress plugin's code:

 function my_plugin_unique_style() {
      $base = get_stylesheet_directory_uri();
      wp_enqueue_style( 'style-my-plugin-style', $base.'/styles.css' );
 }
 add_action('wp_enqueue_scripts', 'my_plugin_unique_style', 11 );

Of course you will have to modify this to use your plugin's css file name but this is the basic way to do this and have valid markup. It's worth mentioning that if this still loads before another CSS file in the HEAD of the page you should bump up the number from 11 to some other higher number.

You can read more about wp_enqueue_scritps here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.