Table of Contents
Well, sometimes we need to implement ajax functionality to our WordPress theme or plugins.Find below a tutorial written for this purpose
Step 1 : create a page in theme
For example to use ajax, I have create a page in theme that show unapproved comment and allow user to approve it .Find below it's code
Step 2 : Create function as per your requirements inside functions.php of theme folder or in your plugins file .
example :
Step: 3
After put below hooks just below above function add_action('wp_ajax_comment_approve', 'comment_approve'); add_action('wp_ajax_nopriv_comment_approve', 'comment_approve');Step:3 call Ajax request in your template file example: