In the comments section of Disqus in Genesis article, a couple of users asked how the standard WordPress comments can be loaded on demand.
In this tutorial we are going to look into how comments section (comments list and comment form) in Genesis can be hidden on singular pages (typically, Posts) by default. The comments section will smoothly fade in to view when a "Show Comments" button is clicked. When the comments section is visible, we shall change the button's label to "Hide Comments" which works as one would expect.
Before:
After:
When "Show Comments" button is clicked, comments section will appear below and the button's label changes to "Hide Comments".
Screencast:
This tutorial only covers showing the comments section on demand, not loading it (dynamically fetching) on click. If you are interested in true dynamic loading, follow this tutorial instead.
Step 1
Create a file named say, singular.js in your child theme's js directory having the following:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thanks. You’re the best.
Hi Sridhar,
Perhaps, I over complicated my request on your Trello board. This tutorial comes very close to what I’m trying to accomplish with my request. Only difference is I would like to show/hide comments in a simple overlay modal. The other customizations that I mentioned in my Trello card I can manage myself.
My need for this is two fold:
1. Comments , imho, are visually obtrusive as a design pattern. They don’t scale well and I would prefer not to see them in the normal flow of my post content and theme design.
2. I plan on implementing infinite scroll for my single posts (like qz.com) and having visible comments at the end of an article would make that difficult to accomplish.
Can this tutorial be easily modified to address my request?
Thanks as always.
Does this work with Genesis 2.6+? I don’t seem to be having any luck, but maybe it’s just my theme.
Yes.
Just tested in Sample 2.6.0 and it is working fine.
Can you provide the URL of your site where it is not working?
Thanks for your help! The URL is https://jesshuff.com/
[…] one of my previous tutorials titled How to Show Comments on Demand in Genesis, I showed how we can hide the comments section and display it when a button is […]