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:

http://digwp.com/2011/02/ajax-requested-page-return-only-content/

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:

http://wp.smashingmagazine.com/2011/10/18/how-to-use-ajax-in-wordpress/

http://codex.wordpress.org/AJAX_in_Plugins

http://wpajax.com/

http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/

Wp Ajax – WordPress Hook to Handle Ajax Request

http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

http://www.1stwebdesigner.com/css/implement-ajax-wordpress-themes/

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.