bloginfo url in javascript

by Omer Gilboa   Last Updated October 19, 2019 20:08 PM - source

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;



Related Questions


Woocommerse image url as product image

Updated April 10, 2015 22:03 PM

How to add an image to a custom url?

Updated July 30, 2017 23:08 PM


Wordpress url image redirect to the homepage

Updated February 19, 2017 09:08 AM

Image from URL Wordpress Plugin

Updated August 23, 2019 15:08 PM