[英]How to include external code/library javascript on wordpress?
I want to use a external JS library on wordpress, how I should add it to my wordpress libraries. 我想在wordpress上使用外部JS库,如何将其添加到wordpress库中。 The library is viewerjs.
该库是viewerjs。
Use enqueue styles code 使用入队样式代码
<?php
function add_theme_codes() {
wp_enqueue_style( ‘style’, ‘your external file url goes here’, ‘all’);
}
add_action( ‘wp_enqueue_scripts’, ‘add_theme_codes’ );
?>
make sure that you have included wp_head
tag in head tag 确保在head标签中包含
wp_head
标签
Taken from the documentation: 从文档中获取:
https://developer.wordpress.org/themes/basics/including-css-javascript/ https://developer.wordpress.org/themes/basics/including-css-javascript/
Enqueue the script or style using wp_enqueue_script() or wp_enqueue_style()
使用wp_enqueue_script()或wp_enqueue_style()排队脚本或样式
Example: 例:
wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array ( 'jquery' ), 1.1, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.