wp_enqueue_script creates Fatal Error
The following is what I have in my code for a custom theme. However I'm having issues with attaching my custom_script to the footer.
09 <?php 10 function my_scripts_method() { 11 wp_enqueue_script( 12 'custom-script', 13 get_template_directory_uri() . '/js/custom_script.js', 14 array('jquery') 15 ); 16 } 17 add_action('wp_enqueue_scripts', 'my_scripts_method'); 18 ?>
yields the following error for me.
Fatal error: Cannot redeclare my_scripts_method() (previously declared in *filename_removed*.php:12) in *filename_removed*.php on line 10
Answers
The error is telling you that you already have a function called my_scripts_method. Just change the name of the function:
function my2_scripts_method() { // blaa blaa blaa } add_action('wp_enqueue_scripts', 'my2_scripts_method');