How can I include 3rd party library in WordPress?

You have to include libraries CSS and JavaScript files to your theme (preferably in your Child Theme to keep customizations separate from the parent theme’s files). In order to do that you enqueue scripts and styles in the themes functions.php file. From the Including CSS & JavaScript Theme Handbook:

Enqueue the script or style using wp_enqueue_script() or
wp_enqueue_style()

So you could upload CSS and JavaScript files to your themes directory and load them like that:

wp_enqueue_style( 'caption-style', get_template_directory_uri() . '/CaptionHoverEffects/component.css' );
wp_enqueue_script( 'caption-script', get_template_directory_uri() . '/CaptionHoverEffects/toucheffects.js' );

Enqueueing is the recommended method of linking JavaScript and Stylesheets to WordPress generated pages. Mostly it’s to keep things running smoothly and let WordPress handle the how and when of loading files and handling dependencies.

Leave a Comment