I want to display a shortcode through jquery after the DOM is loaded:
This is how I call the shortcode: <?php echo do_shortcode('[plugin]'); ?>
Now, my question is how can I call that shortcode inside a jquery function, because my website is based on jquery/ ajax calls?
Thanks!
Javascript code is running in the user’s browser and not on your server (where your wordpress content resides). You could use ajax to call the function which the shortcode is pointing to.
Here is how I handle AJAX calls with WordPress:
1) I use a jQuery ajax function to call the wp-admin/ajax.php
2) This PHP code is located in the functions.php file of your theme or in a custom plugin:
I hope this points you in the right direction.