try this:
function reload_article_content() {
check_ajax_referer( 'reload_article_nonce', 'security' );
$post_id = intval( $_POST['post_id'] );
// only run on posts where 'is-live' custom field is set to 'true'
if ( get_post_meta( $post_id, 'is-live', true ) === 'true' ) {
$post = get_post( $post_id );
if ( $post ) {
$GLOBALS['post'] = $post;
setup_postdata( $post );
ob_start();
the_content();
$content = ob_get_contents();
wp_send_json_success( [ 'content' => $content ] );
} else {
wp_send_json_error( 'Post not found' );
}
} else {
wp_send_json_error( 'Post is not live' );
}
wp_die();
}
Related Posts:
- Filter to remove image dimension attributes?
- Change WordPress image URLs via filter
- Always use for post images
- Change html structure of all img tags in WordPress
- Default Image Link Removal
- Remove title attribute from images
- hook into completed image upload filter
- Need help building a filter to edit the output of “image_send_to_editor”
- Filter Media Library by author or post_parent
- Preview Image Path in Admin Section
- How to display a shortcode caption somewhere other than the_content
- Alter image output in content
- How can I remove the image attachment ALT field?
- add data-attribute to all images inside the_content()
- Filter to modify post_title after image upload?
- Change html structure of all img tags in WordPress
- Disable wordpress image sizes generation
- Extend core block attributes in post content
- What’s the proper way to use the get_image_tag filter?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- How to get image ID to use inside wp_read_image_metadata()?
- Is there any action/filter hook to use when an image gets edited in the editor?
- AJAX – save an $_FILES picture in media library
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- Get image URL after image created from canvas and sent to WP uploads with AJAX
- How can I use cached images in an AJAX response?
- How to add custom classes to figure element only if image has caption?
- Change align classes for images
- How to filter the image embed code based on link type
- Help to upload post attachments from Ajax
- How to implement secure frontend image upload? [closed]
- Add custom text in the media library image meta area
- WP 5.3 Removing Default WordPress Image Sizes
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Remove Image Sizes in Media Settings Page
- How can I use wp_save_image_editor_file filter?
- How to stop WordPress from completely overriding my tags in my templates?
- Adding srcset to an image in ajax
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- How can I change the to for lazyload wp smilies
- How to display a warning when an uploaded image is too small?
- How to change an image source when rendering on frontend?
- How to change Gallery image url in product page ? In function.php?
- How to get title of images in post content
- How to generate alt attributes with php / filters?
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- js alert in add_filter function for image_send_to_editor
- Dinamically modifying attributes of images on posts
- How to attach post ID to image links in WordPress tinymce editor
- What is the best way to handle Ajax image upload on front end?
- image_send_to_editor filter – Unwanted paragraphs and line breaks
- How might one programmatically set the link for all images in all posts?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- Surround uploaded image link with div
- Removing image dimensions from `the_content`
- Display ajax preloader for large images within posts
- Rename uploads filenames to POST-ID on upload
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to add a link to media file for every image inserted in content?
- Image Attachments Query Not Working If Post Is Loaded Via Ajax
- Replace image with its alt text?
- Get field added via attachment_fields_to_edit filter in Gutenberg
- Neither intermediate_image_sizes_advanced or intermediate_image_sizes filter is firing
- ‘Add Media’ to post – filter images
- How to load only a certain type of image (functions.php)
- Remove tab on product for one category, keep but change image for another
- Set default image sizes in WordPress to hard crop
- How can I add the “Use as featured image” to a custom metabox?
- How does WordPress work out the srcsets?
- help getting featured image using get_posts
- Why can I not view image attachment pages?
- Restrict Image Uploads to a Certain File Type
- How to display alt tags in img src?
- Big Image on Featured Post, Normal on Single Post
- Making images in posts link to the image file rather than the attachment page
- How to stop wordpress always displaying full-res images
- Transfer only original images to new site
- Rewrite all article pictures to link to file
- Upload box media size not working
- Featured images disappear after DB export/import?
- I want to Add My Product Image to Admin Order Email in Woocommerece [closed]
- Changing Image Size Settings does not show in Image Details
- Get the URL, width and height of an image where the width and height are a specified minimum
- Metabox image upload value
- How to disable a WP Image Block to link to itself?
- Is there a layout to place 2 same sized images in two columns on the WordPress page?
- WordPress on IIS works except for image upload widget: Win 10 Pro
- How to show a full page when someone links directly to an image on my site
- Can i use my Old Post image URL in my new post?
- Responsive Featured Images Not Working
- How can we achieve this image css style?
- WordPress 404 Images – Images not found after deleted from media
- How to Make Only Images Connected to a Post Show? Not Entire Media Collection?
- Bypass wp_safe_remote_get()?
- Redirect Causes Missing Images
- Specify which image sizes are created on a per image basis
- Hover images and Videos
- How to make Media Library files private?
- How to add embed image in comments?