You can add your own AJAX API for do_shortcode
. Add this to a suitable location (i.e. functions.php
or a plugin):
add_action('wp_ajax_doshortcode', 'ajax_doshortcode');
function doshortcode() {
echo do_shortcode($_POST['text']);
die(); // this is required to return a proper result
}
And this to your Javascript:
$.ajax({
url : ajaxurl,
data : { action : 'doshortcode', text : <text> },
type : 'POST',
error : function(req, stat, err) {...},
success : function(data, stat, req) {...}
});
ajaxurl
is defined on admin pages; see here for instructions for viewer-side applications.
Alternatively, you can set up such actions for all API functions you need, wrapping the original calls with do_shortcode
.
Related Posts:
- WordPress Shortcode / Only works in classic editor, gutenberg error / invalid json response
- WP Rest API – How to get featured image
- Using get_option() in JavaScript
- Tinymce – How to hook before or after live shortcodes rendering?
- How execute shortcode with javascript
- WP_enqueue_script inside shortcode?
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- How to enqueue script based on post category?
- Pass javascript array to shortcode
- Add custom setting that uses radio button to WP Gallery
- Convert HTML Script to Shortcode [closed]
- Preserve shortcode content formatting
- Get Required Assets (JS, CSS etc) for post using REST API
- Gutenberg Block with Select from JSON-File
- Scripts for shortcode: concatenate or load separately? [closed]
- Adding javascript actions to words in post content
- Add JS in footer via shortcode?
- Regenerating WordPress shortcodes based on value with AJAX
- how to use nimble-API and Display data?
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- pass complex json as shortcode parameter
- Displaying an interactive web map on my wordpress site
- Third-Party API – PHP Fatal Errors Paired with http_request_failed / cURL error 28
- Multiple shortcodes with embedded JavaScript code in same page, how?
- Simulate shortcodes with javascript
- wp_register_script and wp_register_style when shortcode is used
- Can JavaScript connect with MySQL?
- Using setTimeout on promise chain
- Shortcode outputs at the top of the_content
- Combining shortcode and get_template_part
- Escaping quotes from shortcode attributes
- How to get current page title inside a page itself in a shortcode and in page content
- Short code to display a loop
- shortcode inside another shortcode
- Custom Shortcode AJAX 400 Bad Request
- WordPress core responsive video not working with shortcode
- conditional shortcode not working
- Wraping $content into link with shortcodes
- Why use JSON API to display recent posts?
- other shortcodes in Contact form 7 MAILS [closed]
- Remove empty p-Tags in Shortcode content before non p-Tags
- What is a short code?
- How do I combine my shortcodes?
- Bulk converting shortcodes to blocks with embeds
- How to add source code into wordpress post really?
- shortcode_atts – one URL variable not working
- Caption shortcodes not including caption as attribute
- Make shortcode’s Bootstrap CSS override the theme’s CSS, how?
- Passing a nested shortcode as an argument of another shortcode?
- JSON API plugin, Get posts by category return no post
- Change the default video shortcode
- How to use shortcode in js url
- Pass data from wordpress to javascript in JSON
- How to add AJAX in a custom PHP function using Google sheets API
- Shortcode to show current post category with link
- How to register a user via modal after clicking a link in the shortcode?
- WordPress TinyMCE : Get value of popup button
- Freeze a shortcode in place?
- Unable to the get the gallery inserted between shortcodes
- Complex Slider Shortcode Help
- Using _e() on text inside video tags prints that text, instead of only showing when html5 element is not supported
- Youtube shortcode
- Shortcode will not pass attribute through to my function [duplicate]
- Displaying audio player as preview in audio post in WP3.6
- How to edit blog page in wordpress? there is no place to put shortcode
- How to transform WordPress user role code to WP shortcode?
- Does short-code slow down my WordPress site?
- redirect if shortcode exists
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- ob_get_clean(); doesn’t return $value in shortcode?
- Content between shortcodes
- Parsing a shortcode through an author meta textfield
- Adding YouTube button to TinyMCE editor
- How to find out what handler is registered to a shortcode
- Shortcode strips formatting and returns at content top
- do_shortcode within a shortcode
- tiny_mce_before_init preventing custom shortcode icon appearing
- Custom Fields – Boolean Display of True/False to Yes/No
- How to display NextGEN gallery in templates?
- Twitter bootstrap tabs
- jQuery Tabs in Shortcode API
- Echo Extra Shortcode HTML to wp_foot
- How can I use a plugin shortcode inside of a html form?
- Disable wpautop on Shortcode attributes
- Remove escape characters from JSON string pulled from a database
- remove shortcode pagination for specific url referrer
- Shortcode PHP file for two conditions passed when do shortcode
- update_metadata() appends shortcode data for every page refresh
- Replacing entire tag with shortcode – JavaScript [duplicate]
- Add audio file to post using custom term meta field as link [closed]
- Display tags cloud from a specific category ID with a shortcode
- Shortcode appeared twice on page, one time before content, one time where it’s really called
- How to list child pages with excerpts, e.g. [child-pages depth=”1″ excerpt=”1″]
- Video shortcode outside WordPress not working with IE and mediaelement’s Flash fallback
- Inserting a variable into a shortcode inside php
- Clarify: Enqueueing scripts within shortcode only loads in footer?
- Create plugin/function to catch XML-data via Shortcode
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- I have the query code but not the shortcode
- wordpress how to sort posts on custom data with plug-in “Search & Filter”