Learn to use Ajax in WordPress

There’s nothing stopping you using AJAX for a single page website that loads in other pages dynamically rather than going to a whole new page. I would advise you build the site without the AJAX and then add AJAX on top so that everything degrades gracefully should an error occur or if javascript is turned off.

So assuming that you’ve now got a site that works almost as you intend but without the AJAX, you can easily just wrap all your content in IDs that jQuery could pick up and request URLs on hyperlinks via JS requests instead of letting the browser handle it.

That’s be answer in its most crudest form.

You can adjust your templates too so that if the request was made by AJAX they only return the relevant content rather than a full blown templated page:


Alternatively you can implement arbitrary AJAX callbacks, here’s a list of articles on how to write use and extend the AJAX callbacks WordPress provides:





Wp Ajax – WordPress Hook to Handle Ajax Request



Loading WordPress posts with Ajax and jQuery

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.