I'd like to display only 1 comment (the most recent one) in node page. And I don't want the pager to be displayed too.

Is there any way to do it without writing custom module?

Could I use mytheme_preprocess_page($variables){} for that?

Thanks in advance.

  • Simply set comments per page to 1. you can see settings in content type edit page. – niksmac Aug 14 '12 at 14:10

First install and configure "Comment goodness" module - it will allow you to sort comments to display newest first.

Then in your template.php create.

function THEME_preprocess_comment_wrapper(&$variables) {
   // Remove pager.  
   unset ($variables['content']['comments']['pager']);
   // Leave only latest comment.
   $last_comment_id = reset(element_children($variables['content']['comments']));
   $variables['content']['comments'] = array (
     $last_comment_id => $variables['content']['comments'][$last_comment_id]

Your Answer

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