JavaScript in WordPress

0

I need to insert a script in a wordpress page but at the time of execution it does not show me the script, I do not know if I need to add it in the base code of the wordpress page or add a plugin

<script type='text/javascript'> width=640, height=480, channel='CanalCNC', g='1';</script><script type='text/javascript' src='http://www.liveflashplayer.org/resources/scripts/hliveFlashEmbed.js'></script>
    
asked by Victor David Chavez Moralez 18.04.2018 в 17:33
source

1 answer

0

One way to do this is to edit the file functions.php of the theme by adding something like this:

function incluir-javascripts()
{  
    wp_register_script( 'hliveFlashEmbed', '/resources/scripts/hliveFlashEmbed.js',array( 'jquery' ) ); 
    wp_enqueue_script( 'hliveFlashEmbed' );
}

add_action( 'wp_enqueue_scripts', 'incluir-javascripts' );

You have to register the script and then add it to the queue, for wordpress to load it.

The add_action function uses the Hook wp_enqueue_scripts which will execute the function incluir-javascripts

The wp_register_script function is used to register the script. and it supports several parameters. Here more information about the parameters it supports.

The wp_enqueue_script function is used to queue the script.

    
answered by 18.04.2018 в 18:34