[wp-hackers] "deprecating" direct calls to wp-config.php

Andrew Ozz admin at laptoptips.ca
Tue Nov 17 18:55:58 UTC 2009


Olivier wrote:
> Thanks sir, that did the trick! ajaxurl is perfect, thanks a lot! Not
> sure if it works for the frontend as well.

The ajaxurl JS var is available only in the admin. To use it on the 
front-end you can declare it from your plugin:

add_action('wp_head', 'my_ajaxurl', 1);
function my_ajaxurl() {
?>
<script type="text/javascript">
   var ajaxurl = "<?php echo admin_url('admin_ajax.php'); ?>";
</script>
<?php
}


More information about the wp-hackers mailing list