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
- Shortcode content is not showing. Only the [shortcode-tag] is showing
- How do I ensure I can loop through every enqueued script and CSS?
- WordPress with React: Saving and Using Data Collected with fetch
- How to avoid conflict if a plugin already have included open library?
- Plugin Activation Causes wp_register errors
- AJAX call of function containing javascript which is not loaded (Plugin development)
- XMLHttpRequest to open PHP file responds with Missing Page
- Including content into an add_shortcode() function
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Replace the WordPress Media Library Uploader
- Using JavaScript in WordPress page to call for server data using AJAX
- Javascript not being loaded only in custom taxonomy template
- Filterable posts using categories
- Ajax Response Error | just getting error as the response
- Add language localisation to javascript alert?
- Some data has already been output, can’t send PDF file – fpdf issue in WordPress
- Enqueue scripts based on site.
- How do I make two shortcode use the same id and increment it when I use them multiple times?
- Shortcode from a plugin not working
- Uncaught ReferenceError: kpoejy is not defined
- How to enqueue an external Javascript file to Frontpage footer
- How to display archive by selecting year and then selecting month
- Which filter to use to pre-parse form elements, which are generated by plugin’s shortcode?
- Remove from a div by class name from post page if post author role is not administrator
- Caption Shortcode: what filter to change the image size?
- 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?
- How to add conent (text) to Add New pages form of admin in WordPress
- Do a summary based on sections in a post
- Script work on non logged in user but not work for logged in user?
- Children Shortcodes?
- Wrapping shortcodes in another shortcode
- Identifying a Page Containing Shortcode at `init`
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- How to show custom taxonomy child posts through shortcode in WordPress
- Multi-part form and wp_redirect()
- add short code not working
- Create pages for authors
- Loop output for custom plugin [solution found]
- 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
- Enqueue Script in custom plugin before other
- JavaScript file successfully registered but does not render correctly
- Correct usage of scripts with shortcodes
- How to Pass ID through Short Code
- wp_register_script and wp_register_style when shortcode is used
- Shortcode attribute “title” doesn’t appear in $atts array
- How to only Load scripts on variable products page
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Developing a wordpress.com shortcode [closed]
- How can i add insertion point between inner blocks in my custom block like core blocks
- WordPress simple ‘Hello World’ plugin – problems
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How to get the value entered in the input field in wordpres
- 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 display .ptm file in my WP site without JAVA
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- Developing an IP lookup function using an API
- Insert meta-description into Yoast-SEO input-field via JavaScript
- Reinitiate Gutenburg’s blocks using javascript
- how to add contact form 7 shortcode in javascript variable
- Insert text programmatically in WordPress Gutenberg Editor
- wp_enqueue_script() with unknown path and maybe symlink
- Javascript function defined in view.js not reachable from save.js
- How to move custom gutenberg block controls from settings to styles tab?
- How to use useSelect to retrieve the currently default fontFamily?
- Shortcode to return data instead of outputting HTML?
- Event when Modal is opened/visible
- How to apply a javascript code on certain parts of elementor made pages?
- Cannot call a class as a function in block plugin react component
- Extend backbone for add new custom Rest Api
- Gutenberg Static blocks: viewScript doesn’t import css for frontend?