简体   繁体   English

关于Skeleton Wordpress主题的自定义JavaScript?

[英]Custom javascript on Skeleton Wordpress theme?

I tried this : http://themes.simplethemes.com/skeleton/tutorials/how-to-add-custom-css-and-javascript-using-a-child-theme/ 我尝试了这个: http : //themes.simplethemes.com/skeleton/tutorials/how-to-add-custom-css-and-javascript-using-a-child-theme/

And I added this in my functions.php inside my child theme directory : 我在我的子主题目录下的functions.php中添加了此代码:

function my_custom_javascript() {
    wp_enqueue_style('additional', get_stylesheet_directory_uri().'/js/additional.js',     array('jquery'), '1.0', 'screen, projection');
}
add_filter('child_add_javascripts','my_custom_javascript');

Of course I have created the file skeleton_childtheme/js/additional.js 当然我已经创建了文件skeleton_childtheme / js / additional.js

but it doesn't do anything and my additional.js is not loaded. 但是它什么也没做,而且我的Additional.js也未加载。 Any idea? 任何想法? :( :(

wp_enqueue_script( 'vantage-bg' , get_template_directory_uri() . '/js/dynamicbg.js', array('jquery'), SITEORIGIN_THEME_VERSION ); wp_enqueue_script('vantage-bg',get_template_directory_uri()。'/js/dynamicbg.js',array('jquery'),SITEORIGIN_THEME_VERSION);

Use this format, name for your script, directory, location of the file , dependency , and the theme name 使用此格式,脚本名称,目录,文件位置,依赖项和主题名称

add_action('wp_enqueue_scripts', 'load_javascript_files');
function load_javascript_files() {
    wp_register_script('additional', get_stylesheet_directory_uri() . '/js/additional.js', array('jquery'), true );
    wp_enqueue_script('additional');

} }

did the trick. 做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM