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 in Browser Console.
Also, check This Post to enqueue Scripts / styles when shortcode is present.
Related Posts:
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- Use js script from one plugin in another plugin
- How to include jQuery and JavaScript files correctly?
- Load js/css files only on specific admin UI pages
- jQuery in header or footer
- Pass javascript result to shortcode executer function
- Pass $this to function nested in another public function of the same class
- Dequeue / Deregister script and replace it with a new plugin
- How do I add a javascript file to all admin pages via a plugin?
- is_page() function doesnt working
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- Loading scripts with wp_register_script and wp_enqueue_script
- Where to call wp_enqueue_script in a plugin with custom template?
- React JSX in WordPress Plugin Development
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- should i be checking for jquery before enqueing it in a plugin
- Custom Plugin – CSS works, JS doesn’t
- How to make my shortcode load scripts and styles, from within the plugin?
- How to insert HTML/CSS/JS into my iframe plugin?
- Is “document loaded” different on admin side than public side?
- Append php file to footer
- Pass javascript result to shortcode executer function
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- the second js file enqueued inside wp plugin isn’t read
- Enqueue Scripts / Styles when shortcode is present
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Can I use the wp media uploader for my own plugin?
- Customizing the 3.5 “Add Media” popup (Backbone.js)
- How would I create a plugin for my shortcodes?
- How to prevent newline from appearing in shortcode?
- Shortcode adding p and br tags
- enqueue script only if it is not already enqueue
- Hook the Keydown Event in the TinyMCE Post Editor
- lodash dependency in a Gutenberg plugin
- Including javascript for a shortcode
- How to get shortcode to work inside a foreach loop called within a shortcode?
- Get returned variable from a function to add_shortcode function
- How do I only load js on the post-new.php and post.php pages in admin?
- creating elements/innerblocks via rangecontrol
- What is rich_editing?
- Why is my shortcode not working
- On plugin deactivation hide its shortcode
- Inserting JS snippet in the footer if there is no wp_footer?
- Gutenberg – What is the best way to save/update post meta?
- Is it possible to delay execution of shortcode output callback?
- How do I write a shortcode that opens and closes?
- Gutenberg Block showing invalid content on edit
- Is there a way to ensure plugin script loads before another script?
- Storing product price data in the database
- What is the proper way to include Bootstrap when executing a shortcode
- WordPress Plugin with a shortcode that dynamically generates javascript. Can I use add_action without wrapping the javascript in a function?
- conditionally load javascript & CSS for do_action() calls from plugin
- What stylesheets are available in core?
- Enqueue WordPress plugin scripts below all other JS
- Creating a custom Gutenberg block with columns
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- Gutenberg: import dependency or assign from global variable?
- add javascript files only when plugin is called?
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- Inserting code to HTML view from a pop up initiated from visual view
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- wp_nonce_field displaying twice
- WP Plugin Running before jQuery
- Using a custom shortcode from within the template of a shortcode plugin
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- Plugin Development – Class Constructor Not Firing wp_enqueue_style action hook
- Automating the process of shortcode generation in a plugin – how is it done?
- How to enqueue scripts in right way in a plugin?
- Create Widget or Enable Shortcodes in Sidebar
- admin_enqueue_scripts not rending JS file correctly
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Using function from enqueued .js file in theme in plugin?
- add_filter img_caption_shortcode not implemented
- Is there a WordPress plugin to design WebGL? [closed]
- Font size of HTML content
- How to write a shopping queue line plugin with a queue button?
- wp.media gallery collection sometimes undefined
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- How to write a custom shortcode name book?
- How to use setAttributes outside of the edit function return
- Reading plugin settings in esnext wordpress block
- Dynamically modify content added to table via javascript
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Add language localisation to javascript alert?
- Shortcode from a plugin not working
- Remove from a div by class name from post page if post author role is not administrator
- Enqueue script not working
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- WordPress simple ‘Hello World’ plugin – problems
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How react js and other Javascript Technologies works on WordPress plugin?
- Shortcode rendered in preview, but empty in post
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- How to use useSelect to retrieve the currently default fontFamily?
- Event when Modal is opened/visible
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?