In this members-only tutorial, we share a simplified blueprint/template for dynamically fetching/loading any piece of content (PHP code) when a link/button is clicked i.e., on-demand in WordPress.
Here's what happens behind the scenes in a nutshell:
- User clicks on the button
ajax()function while passing it a) the URL to the file in WordPress AJAX API responsible for handling AJAX requests and b) name of an "action"
- Request gets sent to
admin-ajax.phplooks at the registered action and runs the function hooked to this action
After implementing the steps in this tutorial and seeing them work, you can easily duplicate/extend this for your own specific requirements.
Install and activate My Custom Functionality plugin.
Connect to your hosting account using a FTP client and navigate to site's
Create a file named say,
ajax-blueprint.js in the plugin's
a) add the following inside the
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $599 one-time).
Already a member? Log in below or here.