I have a WordPress based website, and some of the content is loaded through javascript.
For example:
jQuery(".portfolio-fs-slides").css({"display":"none"}).prepend('<div class="portfolio-fs- slide current-slide portfolio-ppreview"><div class="project-coverslide"></div><div id="content" class="content-projectc contenttextwhite"></div></div>');
What I want to do is append this shortcode: <?php echo do_shortcode('[daisy]'); ?>
But as far as I know is not really possible to append php code in javascript.
Is there any workaround to accomplish this ?
Thanks!
As @Bergi mentioned, the PHP will run serverside, and the JS will run client side. You can output JS (or parts of your JS) via PHP and have it run client side, e.g.
One way to think of this is that since PHP runs server side, it will always run before the JS is parsed.
Put another way, you could have a javascript line like this: