You should really take a look at the AJAX in Plugins article. It gives examples of how to setup AJAX the proper way in WordPress.
Here’s the basic workflow of using AJAX in WordPress:
- Create an enqueue your custom JavaScript file that uses jQuery.post or jQuery.get or jQuery.ajax
- Create a callback for the wp_ajax action hook (learn the difference between normal and nopriv hooks)
- Within your callback function, you would create some logic that would echo whatever type of content you choose (make sure to exit or die() at the end of the callback)
It’s best if you learn to fish on this one rather than someone doing the fishing for you. 🙂
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Autogenerate wordpress shortcodes using array?
- Loading shortcode with ajax
- Adding Custom Fields for Img in Posts
- Shortcode display outside the div
- Execute a function using ajax
- Shortcode under a Shortcode Multiple times Possible?
- Calling shortcode in wp_localize_script strips result
- What’s the point of using WordPress’s built in admin-ajax.php?
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Shortcode in AJAX popup
- jQuery Plugin to use WordPress functions in AJAX request
- ajax front-end increment views on click
- Trying to count the total number of paragraphs inside a blog article
- May i Use ShortCode in Template?
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- Prevent shortcode from being wrapped in tags
- AJAX button run function
- Adding Shortcode to Text Widget
- How to put JQuery/Ajax inside shortcode?
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- creating html reusable blocks via shortcodes
- How to create an input field, and base the output on spreadsheet data? [closed]
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Nested shortcode functions accessing variable
- Calling an attribute from a plugin shortcode
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- WordPress metaboxes – textfield suggestion automatically populated
- What is @Action in WordPress?
- Render Modula Plugin Shortcode On Ajax Request
- plugin shortcode not working on ajax request call
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Adding class to last list item? Not WP generated
- Return multiple values ​in a shortcode attribute
- How to get specific string/value from an array? php [closed]
- Shortcode Attributes to Return different $_POST
- Where Should i write the code for wordpress ajax voting?
- strange shortcode error: does shortcodes requires any dependency?
- WordPress function to add text warning on every pages [closed]
- Add the_post_thumbnail_url to a shortcode in function.php
- Adding a Tag Parameter / Filter to My Shortcode
- Elementor Pro display featured image on section -> style -> image using shortcode
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- Create a pdf from the entries in DB
- How to get current cart values using WC_Shortcodes?
- get_post_meta shortcode returns empty field
- Cannot pass value variable to WP AJAX functions
- JS working when used normally but not in wordpress
- Get Shortcode output to database for static post_content
- How to pass multiple custom fields as shortcode’s parameters
- Get shortcode attribute for AJAX call
- Update User Meta Via Ajax
- Compare Ajax Data Results
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- Find all strings between an enclosing shortcode
- wordpress Shortocode running twice?
- AJAX login without a plugin does not work. when add a action to function.php
- Posting code inside the post instead of in the template file using shortcode
- How to load a plugin when doing an Ajax call? [duplicate]
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- echo value from ‘select’ field type into page template using cmb2?
- How to handel multiple checkbox field in the admin settings page with Settings API
- plugin shortcodes not working on custom theme- unsure how to fix
- What is the function to get plugin base url in multisite?
- Code in theme functions.php faster than with a plugin?
- Nested shortcodes
- Override the core function locate_template
- How to remove duplicate Custom Fields?
- WordPress Ajax Callback
- Saving Custom Post types and fields to a custom table
- Inserting HTML tag with ACF into shortcode
- How to Display a Plugin function (content) on frontpage using index.php
- Form isn’t inserting data into database with ajax plugin
- Customize permalink wordpress category id
- Admin style for just one plugin in dashboard
- Load Javascript from Plugin in One Page Only?
- Is it safe to use admin-ajax.php in the frontend?
- Create WordPress posts from JSON array using plugin in admin
- How to use template inside plugin shortcode with variables for big HTML code
- Change Header (Logo) Based on Login
- Shortcode and variable
- Loading by Ajax a plugin that also uses Ajax
- How can i list random author?
- Help with autofilling field
- insert og image link in wordpress post
- How to copy the all WordPress media items to another custom plugin folder?
- Why is my shortcode not working?
- User Following System
- cURL do not mimic click
- function of parent not working in childtheme
- Need help getting a certain value out of a multi dimensional array
- how to create table during plugin installation in side a class
- Why function hooked using object are executing at all time?
- Including a PHP file via a function that is part of a plugin?
- Any way to hook into WP after a page displays?
- Buffered output in chunks and shortcode – how do I achieve that?
- wp_enqueue_script doesn’t load JS in plugin