Jan 13, 2011
Get WP theme directory address using jQuery GET request
first: premise: load jQuery library
1. functions.php in the theme of which add the following function code: Show get_bloginfo ('template_directory') values
function theme_file_url () {
if (isset ($ _GET ['action'])&& $ _GET [' action '] ==' theme_file_url ') {
nocache_headers (); / / (FIX for IE)
echo get_bloginfo ('template_directory');
die ();
}
}
add_action ('init', 'theme_file_url');
2. JQuery code: function with the GET request to obtain theme_file_url () data (data)
var ajax_php_url ='';
$. get ('./? action = theme_file_url ', function (data) {ajax_php_url = data +' / comments-ajax.php';});
In this way, ajax_php_url value is the theme you use http:// directory / comments-ajax.php
Maintained by BPOVIA Web Design Team





Recent Comments