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:
- Ajax call always returns 0
- Use AJAX in shortcode
- 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?
- How to get comments with mixed status using get_comments?
- disable comments if array exists
- Display random text from a file with the WP built-in AJAX API
- Remove “says” from 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
- Ajax call theme functions from front
- ‘is’ functions and ‘get_query_var’ not working
- Show top commenters without using a plugin
- Ajax not working properly
- Change the HTML of the comment form that is generating somewhere from the core WordPress
- Commenter should see only his comments in wordpress
- Function call via ajax – can’t figure it out?
- WP Ajax Function Always Returning undefined
- Scripts not appending to element in AJAX call – why?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- Search filter by Post title OR Meta Title Value [duplicate]
- wp-comment author- url +, email filter hook
- admin-ajax.php + load-scripts.php hanging for minutes
- How to search using ajax for exact phrase or words in an input field?
- Multisite Ajax serialize return error [object Object]
- Where to add the permalink in this function?
- Incorrect redirect after commenting
- comments_popup_link without echo?
- Getting comment count per post not working
- Wp admin – Set default value to 999 in comments
- What is the Difference in bones_comments() and comments.php
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- AJAX error handling for submit function in functions file
- echo custom fields with AJAX
- Dequeue script to prevent javascript event conflict on wordpress child theme
- PHP 7.1 | Warning: A non-numeric value encountered in
- Check if a value exists in database table
- How to use get_posts() function in functions.php
- Are innerHTML elements visible to jQuery functions?
- Ajax resetting my global variable
- contact form in template with jquery,validate and 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?
- Populate Product Regular Price with a calculated ACF Field Value
- post value to function with Ajax and jQuery
- price of product can’t return when get data of product in functions.php
- 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
- 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
- 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
- Automatic add space if user enters number(any digit)
- functions.php filters not applied in AJAX call
- Pass max posts to Javascript
- 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?
- 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
- Add functionality to block comment authors in the Comment edit pag
- 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