Automattic / newspack-blocks

Gutenberg blocks for the Newspack project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Homepage Posts: Add option to display comment count (& support Disqus)

laurelfulford opened this issue · comments

Similar to toggling on and off categories and post dates, it would be helpful to have an option to toggle on and off post comment counts from the Homepage Posts block.

This is commonly done in themes using the comments_popup_link() function. This will print a link to the post with #respond at the end of the URL if there are no comments, or #comments if there are (it will also change the link text -- the default is "Leave a comment" for no comments, or "1 comment" and "2(+) comments" when there are comments).

We could use the same function for the blocks, but ideally format the text differently (eg. a simple comment bubble; don't display if there isn't any comments) so it doesn't eat up too much space in the blocks.

This request originally came from a publisher who is using the Disqus plugin; to get the comment count displaying correctly from a post, it needs #disqus_thread appended to the end of the post link, instead of the standard #comments or #respond generated by comments_popup_link(). This could be done by adding a check for the plugin being active, and adjusting the comment link markup accordingly.