I am trying to generate a WordPress shortcode which will display a bxSlider. The shortcode function itself works like a charm; I can pass my data and the shortcode is rendered properly.
The problem:
In the shortcode I also added an attribute id
, which will be used to pass an ID used to call the slider, so for example:
$(".myid").bxSlider({
So the "myid"
part would be passed like [myshortcode id="myid"]
. But as the script needs to be placed in the footer (using: add_action( 'wp_footer', 'myshortcode_function');
). So, I have to call the id
attribute outside the shortcode function.
Could anybody please explain, how to pass that attribute so I can use it in another function? Please do not link me to the documentation. I read it, and I don't understand it.
$(".myid")
is not applicable forid=myid
use$("#myid")
instead – Shanavas M Nov 24 '15 at 14:06wp_localize_script
to pass the information you need. – Nicolai Nov 24 '15 at 14:07