BPOVIA Website Design

Icon

Provides High-quality Web Design And Maintenance Service In The World

get WordPress theme directory by using Javascript

The first: the output directly to the page address in the page

<script> var themeurl = <? php bloginfo ('template_directory')?> </ script>

This themeurl variables can be referenced directly in the page

The second: style.css file in the test head to obtain the directory (the address directly on the need to reference the js file in the theme)

function themeurl () {
var i = 0, got =- 1, url, len = document.getElementsByTagName ('link'). length;
while (i <= len & & got ==- 1) {
url = document.getElementsByTagName ('link') [i]. href;
got = url.indexOf ('/ style.css');
i + +;
}
return url.replace ('style.css','');
};

This function returns is the subject of your directory with a URL (eg: http:// to your domain / wp-content/themes / your theme /).

BPOVIA All Rights Reserved
Maintained by BPOVIA Web Design Team

Category: website, WordPress

Tagged: , ,

Leave a Reply