Ajax breaks in wordpress if back-end uses SSL

So you have a wordpress blog and you (or your client) want the wp-admin to use an SSL certificate, sounds great! However, any AJAX you use in your site has broken. I spent a while googling this issue when it happened to me and found a really easy fix; you need to change the variables in the get_admin_url() function to force the AJAX requestion to use http instead of https. Change it to look like:


I hope this helps a lot of people!

3 thoughts on “Ajax breaks in wordpress if back-end uses SSL”

  1. Interesting! I am currently having problems with a website I am building, and where I added an SSL certificate. Since then, AJAX went bananas… In what file can I find the get_admin_url() function that I need to change?

  2. Hi Kristof,

    Normally, in the javascript for your AJAX call, there will be a url parameter.
    I, prior to using SSL, would have a line that looked like so:
    url: <?php echo get_admin_url(); ?>/admin-ajax.php
    To get this to work with SSL, I changed it to:
    url: <?php echo get_admin_url(null,'','http); ?>/admin-ajax.php

    I hope this helps.


  3. We are about to launch our site and use the WP Search Suggest plugin but found that turning on WordPress HTTPS breaks it so made a similar change as follows to fix it:

    1) Find file ‘wp-content/plugins/wp-search-suggest/wp-search-suggest.php’.
    2) Search for string ‘admin-ajax.php’.
    3) Change the following string from:

    ), admin_url(‘admin-ajax.php’) ), )


    ), str_replace(“https:”, “http:”, admin_url(‘admin-ajax.php’)) ), )

    Many thanks for your help that led me to workign out this fix :)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>