Can I load posts via Ajax?

I would like to make a portfolio page where each entry (a post) would be fetched using Ajax.

This way I would have an image gallery, but in which I not only would have images but also the description of the work, if it’s for sale, the url to the shop, and whatever other random fields.

A gallery is not good enough because there is no clean way of displaying text belonging to each image’s post.

1 Answer
1

Absolutely!

There are a number of themes on the market that do load posts via AJAX. Take a look at any of them to get an idea of how they work. A particularly good example is K2 – K2 loads entire pages of posts via AJAX if you click on the previous posts link.

To really get your hands dirty, check out this awesome tutorial on loading posts via AJAX.

Just keep in mind, AJAX is all about using JavaScript to request data from a server – your server in this case is running WordPress and is built to produce posts based on specific requests. All you need to do is add the JavaScript layer to request them on demand.

Leave a Comment