Jump to content

Recommended Posts

Posted

Hi, I am wondering if someone can help me out with getting the count of the comments of a page? 

I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page, as below 

 

Screen Shot 2018-05-07 at 7.57.37 PM.png

 

The shops part that you see above is something similar to this 

<?php $set_page = $page->title;
$count = $pages->count("template=prices, title=$set_page");
echo $count;
?>

 

Posted

Hi @mattcohen,

Welcome to the forum. The code should look like this

<?php $set_page = $page->title;
$count = $pages->find("template=prices, title=$set_page")->count();
Posted
6 hours ago, mattcohen said:

I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page

Assuming your comments field is called comments then you get the count like that :

$count = count($page->comments); 

or

$count = $page->comments->count();

 

  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...