Ever thought of allowing readers of your WordPress-powered site to submit comments effortlessly and instantly without reloading the page? If so, this guide tells how to do so.
AJAX is used on WordPress too, and we’ll be making use of the same technology for effortless comment submission on WordPress.
With the traditional WordPress comments, the page reloads as soon as someone clicks the submit button in the comment form. If you too feel the need of effortless commenting on your blog, this cool jQuery AJAX snippet will submit comments on WordPress without reloading the page. You may also customize the code to display custom status message when someone submits the comment on your blog.
Note: Before anything, make sure you have backed-up everything (i.e. your WordPress theme). Also, your theme should be using jQuery for this to work.
Just copy and paste the below given code to the
comments.php file of your WordPress theme – remember that you’ve to add this code at the end of the everything in the file.
- As told before, the code snippet above makes vast use of jQuery’s AJAX. Make it sure that your theme uses jQuery
- In order to customize the status messages, modify the error and success messages in the cove above to the desired messages.
- You may use classes
.ajax-errorto style the status messages with CSS
- To customize the placeholder text, you may change “Processing” to “Submitting…” or something similar.
- To style placeholder text with CSS, use the class
Save changes. Now, make a comment on your site to test whether the AJAX submission is working or not. If you’re getting errors or find this solution not working for you, let me know through comments, I’ll try best to help you out.