All Questions
6 questions
2votes
1answer
89views
Can't get JS code to work with shortcode
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 ...
0votes
1answer
201views
Deactivate JS Script in Plugin Shortcode
I am using a plugin which enqueues a javascript file in one of its shortcode functions (which I run on a page). I don't want this file to be loaded. So I tried using wp_dequeue_script in my ...
9votes
2answers
8kviews
Using get_option() in JavaScript
Previously, I used the get_option() function to get an option in PHP, like this: $width = get_option('my_width'); This is inside a shortcode function. Now, I want to have an option in JavaScript. Is ...
3votes
1answer
4kviews
How to enqueue script based on post category?
I have scripts for various little tools I have made using some js and html. I want the js to load only on specific single posts in side a specific category. I have tried the following code and it does ...
2votes
2answers
7kviews
Including javascript for a shortcode
I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads. I'm having issues trying to decide when ...
2votes
2answers
2kviews
WP_enqueue_script inside shortcode?
I've got shortcode that needs to include JS library only once and only there where it's used. function shortcode_function($atts, $content = null) { $class = shortcode_atts( array('something' =>...