Can’t get JS code to work with shortcode
You need to return the Shortcode generated string, not echo, like this: function gg_product_front_end() { wp_register_script( ‘gg_loadProducts_frontEnd’, plugins_url( ‘js/front_end.js’, __FILE__ ), array( ‘jquery’ )); wp_enqueue_script( ‘gg_loadProducts_frontEnd’ ); return ‘<p id=”test”>Test!</p>’; } Also, you need to call the JavaScript function, like this: function gg_loadProducts_frontEnd() { console.log( ‘Test!’ ); } gg_loadProducts_frontEnd(); Otherwise Test! will not be logged … Read more