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
- Use AJAX in shortcode
- wp_get_attachment_image returns different image size
- AJAX handler throws 400 (Bad request) – why?
- 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
- 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
- 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 know which ajax file or function is called for action
- How to search using ajax for exact phrase or words in an input field?
- Multisite Ajax serialize return error [object Object]
- Create post using Ajax
- Where to add the permalink in this function?
- Incorrect redirect after commenting
- comments_popup_link without echo?
- Wp admin – Set default value to 999 in comments
- WordPress listen to $_POST in functions.php
- 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
- Dequeue script to prevent javascript event conflict on wordpress child theme
- Check if a value exists in database table
- 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
- 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
- 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
- Warning and fatal error
- 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
- 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)
- functions.php filters not applied in AJAX call
- Pass max posts to Javascript
- Updating site content after an AJAX call without a page reload
- Error function main() is a non-object to construct my Ajax.php
- Custom Nested WordPress Comments with avatar
- admin-ajax.php nulls all php variables
- 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?
- 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
- WP backend, Show only own comments (give to users who wrote/published/assigned) posts