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');

Need Your Help

How to check whether a server supports SSL with Java?

java ssl encryption

I need to check whether a server supports SSL and the ciphers from the web server.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.