Peter Turner
Peter Turner

Reputation: 355

How to use AJAX to retrieve data from an external API from the frontend in Wordpress?

I am a newbie and basically I need to make a plugin that displays events on my site. I will be using an external API (eventful) to retrieve the events, and will need to do so in javascript.

I want to provide visitors to the site with a few options checkboxes which give them choices determining which events are displayed: the idea is that the option checked will change the query provided to the API and alter the events being displayed to the visitor? Would anyone perhaps be able to point me in the right direction?

Upvotes: 0

Views: 490

Answers (1)

user1049961
user1049961

Reputation: 2736

it's not difficult once you track down the basics.

For using ajax in Wordpress, you need 'wp_ajax' and 'wp_nopriv_ajax' actions. You can find out how to use them in the codex https://codex.wordpress.org/AJAX_in_Plugins

There also is an interesting article that gives you some great tips for Ajax and Wordpress http://solislab.com/blog/5-tips-for-using-ajax-in-wordpress/

Upvotes: 1

Related Questions