May 2, 2016 at 7:58 pm
#44622
ilayxz
Participant
Thank you very much for your recommendation! It has very helped! 🙂
First I did my script code at interface-child/header.php inserted. So It works marvellous!
But than I was going to enqueue it from functions.php to head section.
Thereto I made the following steps:
- In interface-child/header.php in <head>-area the following code inserted:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
- A new javaScript created: accordion.js in file interface-child/js:
$(document).ready(function(){ $("dt").click(function(){ $('dd').slideUp("fast"); $('dt > a').removeClass('open').addClass("closed"); $(this).next("dd").slideDown("fast"); $(this).children("a").removeClass('closed').addClass("open"); }); });
- To Loading the scripts properly in WordPress, I did pasted the following code in my child-theme’s functions.php file:
function wp_interface_scripts() { wp_register_script('my_accordion_script', plugins_url('accordion.js', get_stylesheet_directory() . 'js/accordion.js'), array('jquery'),'1.0.0', false); wp_enqueue_script('my_accordion_script'); } add_action( 'wp_enqueue_scripts', 'wp_interface_scripts' );
Unfortunately it doesn’t work. Where do I make mistake?
Thank you very much again!