I think the solution is amazingly simple here:
You’re just missing a single line of code in your ajax callback, namely:
global $post;
where I assume you’re using:
$post = get_post( $post_id );
The reason is that there’s a global post check in the WP_Embed::shortcode()
method.
More details in my answer here.
Related Posts:
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- Show spinner GIF during an $http request in AngularJS?
- ASP.NET MVC controller actions that return JSON or partial html
- How to check if I am in admin-ajax.php?
- Ajax in a settings page (update_option is undefined)
- Execute one AJAX request after another AJAX request finished
- Ajax and autocomplete
- admin-ajax.php vs Custom Page Template for Ajax Requests
- Saving (Updating) Post / Page Edits With AJAX
- How do I send an ajax request and get a response back from a function?
- How-to debug wp_ajax_* hook callback?
- Automatically pull newer posts and append to current page.
- AJAX Implementation
- how to use ajax in plugin admin area?
- Load page content with AJAX using Fancybox?
- Dynamically changing navigation links (next and previous) via AJAX
- edit-comments.php comment_row_actions ajax problem
- jQuery UI Autocomplete showing all results
- Why is my AJAX call not working?
- How to Access custom database content with AJAX onClick refresh of div inside member-only WordPress page?
- how to use reCaptcha v3 in wordpress custom login form?
- admin-ajax.php HTTP400: BAD REQUEST – The request could not be processed by the server due to invalid syntax
- WP_Session not acting with AJAX
- Ajaxing in functions.php
- Embedded Twitter feed won’t render nicely when loaded via Ajax
- Enqueue script dinamically
- Most performant way of fetching remote API data?
- Admin-ajax responds with 0 due to empty $_REQUEST
- Help with AJAX front end comment moderation
- Enqueue script in header
- Using ajax with wordpress
- Using foreach inside an ajax function
- wp_ajax_nopriv_xxx is not firing on one site, works on all others. -1 for logged out users
- WP_User_Query ignoring ‘meta_query’ arguments
- Increased CPU load due to admin-ajax.php spam
- Ajax image upload with media_handle_upload and form.js
- Theme Customizer – Conditional Controls
- Edit a different page in WP Customizer
- Get the_content with ajax
- Caching-Plugins and Ajax-Page-Parts
- Ajax loading duplicate post
- Admin ajax error 400 when passing select value to populate another select
- How do I detect in which page ajax_query_attachments_args is loaded?
- Ajax post returning full html page as response
- Which allowed API hooks work to add wp_ajax action?
- AJAX request randomly stop working and returns error 400
- Sending variable from ajax on form submit
- Ajax store response json in variables
- Performance optimization of tree like structure
- How can I set cookies on both secure and non-secure origins at the same time?
- Variable Products Being Added to Cart with AJAX on Shop and Category Pages
- Audio TAG Not using MediaElement When Page is loaded through ajax
- Is it secure to use admin-ajax.php in front?
- How to pass parameters from jQuery ajax into PHP function?
- ajax is returning 0
- How to add ajax url to js using wp_add_inline_script()?
- merge wp rest api query to get posts per category does not work
- WP AJAX post filter > do something with empty value
- How to make a fetch() POST request to wordpress rest api?
- Load more posts in the same category – Ajax + Timber
- How to jQuery Ajax show new data from successful insert?
- ajaxt returning object object [closed]
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Why is the file not uploading to the server?
- Get localize of a loaded javascript
- is there’s a way to get the next page content generated by page break block with ajax call?
- Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, WordPress(AJAX Request)
- Query data after an Ajax insert
- How to get next and previous post into ajax formed modal windows?
- Passing value from select form with Ajax not working
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- Is there a public ajax endpoint?
- Why Ajax Doesn’t Work?
- How can i do public ajax call?
- How to prevent multiple post with same meta value being created simultaneously in WordPress (with ajax)
- Problem when sending file via ajax
- wp_verify_nonce not working on the mobile device
- Frontend AJAX Media Upload returning 404
- Can’t GET Variable from AJAX URL
- How to update cart total after AJAX success
- Change button text after ajax db update
- How to implement AJAX within a class storing shortcode atts as class variables
- Jquery wrap permalink in a data-attribute?
- How do I display posts of a specific day?
- (Frontend AJAX) get post data WITH image thumbnail?
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- Ajax Function call is always returning 0 in front end(without plugin) [closed]
- AJAX Post from same domain to a wordpress page
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Add Ajax loaded posts to existing posts
- Speeding up admin-ajax.php
- admin ajax is not working for non logged in users
- Change search to outpout category name instead of Post type name
- ‘Dehighlighting’ navigation once clicked
- wp_localize_script not create variable in head section
- How to get data with Select AJAX PHP
- Add “load more” functionality to an AJAX response
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- weird Internal Server Error – no error log produced
- At what stage does wp_ajax hooks gets applied during WordPress request?