$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How can I include 3rd party library in Wordpress?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How can I include 3rd party library in Wordpress?

matteradmin6PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 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.

Post a comment

comment list (0)

  1. No comments so far