I partially resolved adding this code:
$args = json_decode( stripslashes( $_POST['query_vars'] ), true );
$args['paged'] = $_POST['page'];
//Set Query Post args
query_posts( $args );
//Set Glboal Post Data
global $post;
$post = get_post( $_POST['post_id'] );
setup_postdata( $post );
//Set global $withcomment = true to execute comments_template() - using comments-ajax.php Template (Root Folder Theme)
global $withcomments;
$withcomments = true;
comments_template('/comments-ajax.php');
and this in my js:
post_id: ajaxfrontendobject_get_comments.post_id,
Now it works but if I click on the page number (using ajax request) on which the site initially loaded (without using ajax) no comment is loaded and I don’t understand why.
Related Posts:
- How to use: WP_AJAX_GET_COMMENTS
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- Use AJAX in shortcode
- Remove Comments Metabox but still allow comments
- wp_get_attachment_image returns different image size
- AJAX handler throws 400 (Bad request) – why?
- ajax live search for post title
- How can I remove the title “leave a reply” in the comment box in twentyeleven?
- change the comment time output to: X time ago instead of actual date and time
- How to get comments with mixed status using get_comments?
- How to prevent deleting of comments when deleting a post
- disable comments if array exists
- Display random text from a file with the WP built-in AJAX API
- Remove “says” from comments
- Display the number of user comments
- Using email_exists() wp function in an ajax request
- How can I rename the WordPress AJAX URL? [duplicate]
- Most efficient way to get custom database records from 20 buttons and 20 tables?
- Display a function using AJAX
- How do I call wp_mail from HTML?
- Unable to get_the_content(); of a post in WordPress via AJAX
- Comments to only be seen by their author
- How to Add a Random Custom Gravatar in the WordPress Comments?
- Ajaxing function in widget class
- Search user metadata with checkboxes via ajax (almost working)
- Check if a value exists in database table
- processing form data with ajax
- Email Exists ERROR into Ajax registration form
- How to use get_posts() function in functions.php
- Are innerHTML elements visible to jQuery functions?
- Function to replace comment’s accented characters before posting
- Ajax resetting my global variable
- contact form in template with jquery,validate and ajax
- get content from page through AJAX
- WordPress comment_form() does not display actual comments
- Get URLs for AJAX Filter Checkboxes WordPress
- Message notification for user
- Woocommerce Variable Product Dropdown for Custom Shop Template
- WordPress comment processing . Default unapproved comments detection before posting
- Detect Ajax call inside pre_get_posts function
- How do I change where “You must be logged in to comment” directs users?
- How do I make the comment disappear after deleting from the database?
- Populate Product Regular Price with a calculated ACF Field Value
- Ajax Form Issues using Lightsail (AWS)
- post value to function with Ajax and jQuery
- price of product can’t return when get data of product in functions.php
- WP AJAX Request Not Working
- Ajax in plugin fails – but only on one blog – no idea why
- Remove nofollow from internal comment links via functions.php
- How can I automatically delete comments that contain a URL?
- Warning and fatal error
- Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role
- How to use `foreach()` in ajax call
- i can’t use wordpress functions in ajax loaded php file
- Multiple Notifications SetInterval
- Function stops working
- admin-ajax.php 403 forbidden only when calling from external file
- WordPress Ajaxifying not working properly
- Comment function for page
- How to identify author in wordpress comments?
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- How to create admin ajax function for my contact form
- admin-ajax.php & my wp-admin folder url showing in header
- wordpress function through ajax not being called
- same get_posts function works diffrently in tag.php and functions.php
- wordpress ajax is not working for dropdown selection
- How can I return the result of my custom function?
- Automatic add space if user enters number(any digit)
- Newest comments first not working
- get_comments not working properly after WordPress v4.4 update
- functions.php filters not applied in AJAX call
- Pass max posts to Javascript
- Updating site content after an AJAX call without a page reload
- Getting error while trying to use custom comment function
- Error function main() is a non-object to construct my Ajax.php
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- Custom Nested WordPress Comments with avatar
- admin-ajax.php nulls all php variables
- Pass jquery var to a function in functions.php
- Undo a function that is not (seemingly) hooked to an action?
- Ajax call does not work for this custom code
- Syntax for a function in order to get post’s title in JSON encoded response [closed]
- Comment Function
- WP Custom Comment Callback Not Responding
- How to remove “login to reply” from individual comments [duplicate]
- Why wp_ajax hooks doesn’t work?
- AJAX values converted to PHP Variables?
- Getting full code of wp_list_comments instead of replacing it
- How can I json_encode the output of my function?
- WordPress Custom wp mail template return full template
- Comment turned Invisible
- User’s Comments Number: Storing it in a meta field for different uses
- Add functionality to block comment authors in the Comment edit pag
- iOS and ajaxComplete
- get page_id in ajax to function in functions.php
- How to get variable from other function inside class function using add_action for Ajax call
- how to call a non-AJAX function from within an AJAX function
- WP backend, Show only own comments (give to users who wrote/published/assigned) posts