简体   繁体   中英

Wordpress and Javascript, whats wrong?

i am making my own custom wordpress theme. And I am having a problem with javascript. I have writing code in the functions.php. All css is working, but I cant manage to make a toggle menu (for responsive purpoises). Maybe I am doing something wrong ? I copy my code from function.php at the bottom. Ps i also created javascript.js for the code. But i can't figure whats the problem.

        function pirma_enqueue_styles(){
wp_enqueue_style('custom_s_s',trailingslashit(get_template_directory_uri()) . 'css/style.css');        wp_enqueue_style('javascript',trailingslashit(get_template_directory_uri()) . 'js/js.js');
}
add_action('wp_enqueue_scripts', 'pirma_enqueue_styles');

If you created the resource file javascript.js , you simply enqueued the wrong script (namely js/js.js ). Also look out for the correct path: You declared that the file is in the directory js .

Also - and more important in this case - to include scripts you need to use wp_enqueue_script() , not wp_enqueue_style() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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