0

Is it possible to get the comments and comment boxes for each post in a loop so users do not have to navigate to the actual single post page to leave a comment (and instead users can leave comments on the page where the loop is placed)?

I am trying to create a shortcode for the comment boxes to be placed inside a loop but the below shortcode only calls the comment box for the current page or single page as per Wordpress Developer guide.

https://developer.wordpress.org/reference/functions/comments_template/

function show_comments_shortcode() { 
 
  global $withcomments;
  $withcomments = true;
    
// This only gets the current single or page comment 
$showcomments = comments_template( '', true ); 
 
// Return Comments for each post in loop
return $showcomments;
} 
// register comments shortcode
add_shortcode('show_comments', 'show_comments_shortcode'); 

Thank you for any feedback in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.