Tagged Questions
2
votes
1answer
53 views
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. ...
0
votes
0answers
13 views
Am i right to assume that i can't conditionally load a javascript file (or not) based on the used shortcodes and values? [duplicate]
Am i right to assume that i can't conditionally load a javascript file (or not) based on the used shortcodes and values?
like in human language
if shortcode exists in the current post and value is ...
0
votes
1answer
71 views
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 ...
0
votes
2answers
97 views
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 ...
2
votes
1answer
219 views
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' ...
14
votes
5answers
4k views
Conditionally Loading JavaScript/CSS for Shortcodes
I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...