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.
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.
Share Improve this question asked Mar 11, 2017 at 21:03 pookiepookie 1011 silver badge1 bronze badge 3- you have access to the theme files? – David Lee Commented Mar 11, 2017 at 22:21
- wordpress/plugins/line-styled-menu – Nathan Johnson Commented Mar 11, 2017 at 22:32
- @DavidLee yup, I sure do, but I don't really want to modify the theme. – pookie Commented Mar 13, 2017 at 10:51
1 Answer
Reset to default 1You 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.