Javascript not working in functions.php
-
Hello.
I am trying to get masonry working on my website but the following code doesn’t seem to be calling the javascript into my footer. Can anyone tell me why not.
Thanks
function portfolio_masonry() { if (!is_admin()) { wp_register_script('jquery_masonry', get_template_directory_uri(). '/js/jquery.masonry.min.js', array('jquery'), '2.0.110526'); wp_enqueue_script('jquery_masonry'); add_action('wp_footer', 'portfolio_add_masonry'); function portfolio_add_masonry() { ?> <script> jQuery(document).ready(function($){ $('#masonry-index').masonry({ itemSelector: '.index-post-container', isAnimated: true, }); }); </script> <?php } } } add_action('init', 'portfolio_masonry');
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Javascript not working in functions.php’ is closed to new replies.