I want to include this library on a single page. I'm pretty new to Wordpress, so I'm not sure how to do this. Is there a plugin which allows one to upload a library and then link to it in HTML of a page/post?

I tried uploading the plugin contents to my wp-content/uploads directory, but I always get 404 errors when trying to link to the library files, even though the paths are correct.


1 Answer 1


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.

  • Why can't I upload them to a directory via FTP and then link to them in a page? Is it for security reasons?
    – pookie
    Mar 13, 2017 at 10:49
  • Actually that is what you should do, upload them via FTP to wp-content/themes/your-theme/. I updated the answer with info about why you should enqueue files and not load them directly. But actually it should work referencing them directly from your template or even from a content page. Check the routes!
    – geraldo
    Mar 13, 2017 at 13:13
  • Aaaaaah! I had been uploading them to content/uploads and other directories.... never thought to upload them to the theme folder! Doh! I will give that a go. Thank you!
    – pookie
    Mar 13, 2017 at 14:35
  • This answer should mention child themes. Jan 20, 2019 at 0:34
  • @JustinWaulters Thanks, mention of child themes added to answer.
    – geraldo
    Jan 20, 2019 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.