0

I'm trying to set <?php bloginfo('template_url'); ?> in a variable on Javascript, and then to set src of an img element, but in the html it's been printed as src="<?php bloginfo('template_url'); ?>" and not as the actually url.

This is how I tried to do it:

var wpTemplateUrl = "<?php bloginfo('template_url'); ?>"; primaryImg.src = wpTemplateUrl;

0

Try using some API from WordPress itself - https://codex.wordpress.org/Function_Reference/wp_localize_script

  • That's did it! Thanks :) – Omer Gilboa Oct 20 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.