How to add external CSS code to your WordPress site
WPCodeBox makes it easy to add external CSS code to your site. This is useful when you want to include 3rd party libraries from external CDNs.
To enqueue external CSS code, we are going to use WordPress native functions. So, first, we create a PHP snippet, and we set it to run on the page we want the external CSS code to be included.
The following code will enqueue an external CSS file:
<?php
add_action('wp_enqueue_scripts', function(){
wp_enqueue_style( '[style_name]', '[style_url]' );
});
Make sure to replace the [style_name] with a name of the script (lowercase characters with no spaces, eg animate_css).
Also, [script_url] is the URL to the external style source (eg. https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css ).
This will allow registering external CSS styles the WordPress way.