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
- Why does my JavaScript work in the browser console but does not work in my shortcode?
- How to add a shortcode that creates an adjacent column of text in the content editor?
- get_posts not working on homepage?
- Execute Shortcodes when submitting post
- Substituting value via shortcode
- Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH
- how to write short code in word press
- Better way to display multiple plugin output on the same page?
- hard code shortcode only on specific category
- Dynamic number within shortcode
- How to turn this HTML code into a shortcode? (adding song lyrics and giving an id to a div)
- get_queried_object_id / short code returning blank
- Video shortcode, option are not rendered
- ACF repeater + group shortcode
- Custom shortcode skips every 2nd shortcode
- How to write a shopping queue line plugin with a queue button?
- Create shortcode for each form field in contact form 7
- Build Clickable Link Using Multiple Attributes
- Set redirect for need login
- Getting Shortcode Attributes befor content is displayed by the template
- make user_id in a shortcode dynamic based on who’s logged in
- How to add site tags in alphabetical order to shortcode?
- How can i strip shortcode from HTML title tag?
- Can’t render shortcode when html tag contains hyphen
- Adding shortcode of “Random Content” Plugin in the post after the title
- Shortcode won’t take into account custom post ID put in parameter
- using shortcodes inside gravity forms
- wordpress script_loader_tag in function.php
- Show content if user left comment / non-logged visitors?
- How to insert current user ID/entry ID into a shortcode?
- Upload Javascript and json webpage to wordpress
- Showing results from json-string in WordPress search results page
- How to remove double quotes in a shortcode?
- Auto embeds don’t work for attachment descriptions
- Shortcode to appear and show the date not code in Title and description of my website
- Template not loading with get_template_part or locate_template
- Shortcode to appear and show the date not code in Title and description of Social Media sites
- Need help with creating a simple shortcode
- Colon is Missing In My Website Url in WordPress Shortcode
- WordPress post shortcode pagination not working
- Wrap template code with shortcodes
- my form does not insert any data in the database
- Using Shorcodes in Sharing Preview and Notifications Title from Post Title
- Not to escape a text
- Using shortcodes in the Site Title
- Returning HTML to Shortcode Block
- Use atributes of shortcode in get template part
- Global $post returns 2 objects for my shortcode
- How to display html element and php string in the same line?
- How to Display Shortcode’s Content after Short Product Description?
- Echo Extra Shortcode HTML to wp_foot
- How can I use a plugin shortcode inside of a html form?
- Gutenberg Shortcode Chooser Block
- WordPress Theme/Plugin Information API Response to Text and Button
- Image Caption Shortcode Broken upon update
- How to cache a custom API call?
- Using a WP shortcode in Homepage
- Shortcode do not return a value
- i want to show a modal when user lands on home page very first time
- Check if parent page has child page of certain slug
- Shortcode not working in CPT taxonomy
- Shortcode not working inside div html
- JSON api oembed youtube
- Is the WP audio shortcode still relevant?
- wp_enqueue_scripts does not work on admin page
- shortcode containing other shortcodes not returning content
- Problem parsing long parameter in shortcode
- Variable inside shortcode or shortcode inside shortcode
- How to utilise multiple values from a single shortcode attribute?
- JavaScript missing from shortcode content
- Hide download option video shortcode
- Can Someone Help me to Correct my shortcode for displaying a category?
- WordPress Shorcode Display hierarchical taxonomy [child, parent]
- From a shortcode I want to pass a value to display a different page