Add javascript in worddpress

0

I have an application that uses wordpress and I need to add a javascript in it, I have seen several videos and posts on the internet and from what I understand it is just to do this:

<?php
    wp_register_script("meuscript", "js/meuscript.js");

    function my_scripts_loader() {
        wp_enqueue_script("meuscript", "js/meuscript.js");
    }
    add_action("wp_enqueue_scripts", "my_scripts_loader");
?>

But I do not know where to add this code I was kind of confused, I saw something about adding to the theme or something

    
asked by anonymous 11.12.2017 / 22:03

2 answers

0

You can put this code in the wp-content / themes / SEU-TEMA / functions.php

function load_scripts() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/myscript.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'load_scripts' );
    
12.12.2017 / 00:09
1

Dude, depending on how your theme is set up, just put the path normally in the theme header that works.

<script src="caminhoDoSeuCodigo/code.js"></script>

I have already done so, I do not understand much of Wordpress but it worked in my case.

    
11.12.2017 / 22:14