ideal identity
ideal identity

Reputation: 71

How to hide Facebook Comments count if post has no comments yet

I have configured my web application to display Facebook comments and comment count in the post details template... It is displaying perfectly when there is a comment, but I would like to hide the "x Comments" part when there is no comment posted.

< fb:comments-count href="[ARTICLELINK]"/>< /fb:comments-count> Comments

This is my template to display the comment count...

In my application's own comments feature, I could use the [hascomments][commentcount]Comments[/hascomments] template...

However, I couldn't find which token to use for Facebook comments.

Upvotes: 0

Views: 1330

Answers (2)

Mike
Mike

Reputation: 36

The span is given the class 'fb_comments_count_zero' if there are no comments, so you can set that class to be display:none in your styleshet

Upvotes: 2

DMCS
DMCS

Reputation: 31870

Put the above code you have into a div with an id="hideMeIfZero". After Facebook has had time to parse the fb:comments-count tag, then use JavaScript to parse the innerText of the div "hideMeIfZero" for the count.

If the count is 0, then hide the div using CSS.

Upvotes: 1

Related Questions