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
- How to enqueue JavaScripts in a plugin
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- Using get_option() in JavaScript
- Register and enqueue conditional (browser-specific) javascript files?
- Optimize shortcode callbacks
- How to provide translations for a WordPress TinyMCE plugin?
- How-to implement admin Ajax inside an admin WP_List_Table?
- Include third party Javascript library which is not included in WordPress
- How do I make specific plugin functionality apply to different sites in a network?
- Filter on the_content ignores shortcodes
- The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache
- WP_enqueue_script inside shortcode?
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- How to enqueue script based on post category?
- How resource intensive is wp_register_script()?
- Multisite plugin development and wp_enqueue_script
- Prevent Javascript Facebook SDK Conflicts in plugin
- Print WordPress username id inside JavaScript
- Mixing Regular Javascript With jQuery in a Plugin
- Deregistering a script in WordPress seems impossible
- Replacing Scripts in Admin Load_Scripts
- Is there an event or an other method that tells me the preview is loaded?
- What is the best way to embed an JS App in a WordPress Page?
- Secure Pages Best Practice
- Is there a way to check for an attribute of a script when using script_loader_tag?
- How to prevent UNDO on guternberg block editor
- Do I have to worry about useState causing a re-render?
- How to force that styles are enqueued in the header?
- wp.template() returns tags in Ajax response
- My WordPress plugin cannot load my JavaScript file
- How to load library scripts in admin from plugins in noConflict wrapper?
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- Create shortcode to echo javascript
- Wrap text around shortcode
- wp_nonce_field displaying twice
- Redirect to another page using contact form 7? [closed]
- How to handle shortcodes through plugin
- WP Plugin Running before jQuery
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- Enqueuing scripts and styles in custom plugins
- Automating the process of shortcode generation in a plugin – how is it done?
- How to enqueue scripts in right way in a plugin?
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Developing the save function in Gutenberg blocks
- How to create ShortCode
- Using function from enqueued .js file in theme in plugin?
- add_filter img_caption_shortcode not implemented
- shortcode tags not working in do_shortcode
- 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?
- Cannot output plugin twice with shortcode
- wp.media gallery collection sometimes undefined
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- WPGut – Updating failed and shortcode?
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- How to write a custom shortcode name book?
- How to use setAttributes outside of the edit function return
- How can we stop showing short code in create or edit post section
- How do I ensure I can loop through every enqueued script and CSS?
- WordPress with React: Saving and Using Data Collected with fetch
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Javascript not being loaded only in custom taxonomy template
- Add language localisation to javascript alert?
- Enqueue scripts based on site.
- Uncaught ReferenceError: kpoejy is not defined
- Remove from a div by class name from post page if post author role is not administrator
- Enqueue script not working
- How to add conent (text) to Add New pages form of admin in WordPress
- On one of my sites a file is shown as 404 but the file IS there
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- How to only Load scripts on variable products page
- How can i add insertion point between inner blocks in my custom block like core blocks
- WordPress simple ‘Hello World’ plugin – problems