Can’t get JS code to work

I am trying to create a plugin and I’ve got stuck. I am trying to register and enqueue a script from a shortcode:

This is my shortcode:

add_shortcode( ‘gear-guide’, ‘gg_product_front_end’ );

This is the function it calls to:

function gg_product_front_end() {

echo ‘<p id=”test”>Test!</p>’;

wp_register_script( ‘gg_loadProducts_frontEnd’, plugins_url( ‘js/front_end.js’, __FILE__ ), array( ‘jquery’ ));
wp_enqueue_script( ‘gg_loadProducts_frontEnd’ );

}

And this is the JavaScript:

function gg_loadProducts_frontEnd(){
console.log(‘Test!’);
}

I am not getting any error, neither php nor js.

Any ideas?

Thanks!

Read more here:: Can’t get JS code to work

Leave a Reply

Your email address will not be published. Required fields are marked *