Wordpress

How to fix ajax url not defined error in wordpress

1. Open function.php file and paste the below code to deined wordpress ajaxurl

/*defined ajax url*/
add_action('wp_head', 'wordpress_frontend_ajaxurl');
function wordpress_frontend_ajaxurl() {
    echo '<script type="text/javascript">
           var ajaxurl = "' . admin_url('admin-ajax.php') . '";
         </script>';
}

Advertisement

Did you find this helpful? Share it!

Leave a Comment

Your email address will not be published. Required fields are marked