WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In relation to this question, I don't understand the meaning of:

Instead of sending the ajax request to the admin-ajax.php, send it to the same url (using js window.location.href ) but including an endpoind that can be 'mobile' or 'desktop'. An hook into template_include filter will do the rest. Hope it's clear

This is my call:

        url: my_ajax_script.ajaxurl,
        data: ({action : 'get_mobile_template'}),
        success: function(data) {

Is there anybody who understands this matter and is able to come up with an example?

share|improve this question
To me you MUST use admin-ajax.php for your AJAX requests in WordPress – JMau Aug 27 '13 at 11:25
but then, how do you conditionally load stuff into the head then? e.g. page specific css styles and scripts. Because if I put get_header() into the template that ajax loads, I get a great white page... – Andrea Puiatti Aug 27 '13 at 11:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.