Why would you want to hide WordPress comments from non-logged-in users?
Here is a good reason for that.
Suppose you run a membership site like this one, and the contents you create with care and dedication are meant for those who subscribe to it.
In that case, you’d want to hide a part of your post from non-subscribers.
For example, if you scroll down this page, you’re likely to see that a part of this post is hidden from non-subscribers.
In a similar way, you’d want to hide WordPress comments section too from non-subscribers.
It’s not as if you’re deliberately against non-subscribers submitting any comments.
In fact, it’s more because of the reason that you want that the discussions in the comments remain confined within the subscribers only.
After all, comments by the subscribers provide deep insights into the issues they are facing after they read your posts, and why should you have them available to non-subscribers?!
Makes little sense I guess.
Having said that, it is a fact that many website owners seek to hide WordPress comments for a wide variety of reasons (not necessarily what I mentioned above).
WordPress makes it easy to control how you want the comments to be in your blog.
You cannot however selectively hide WordPress comments for non-logged-in users unless you deal with some codes, this is not difficult and I’m going to explain it in this article.
Before that let’s look at the options WordPress provides for hiding or removing comments section on the posts.
Options to hide WordPress comments section
There are quite a few ways to altogether hide WordPress comments on the posts and pages, no matter whether the user is logged in or not.
The different options are given below.
On every post or page in which you want to completely hide WordPress comments, scroll down the Add New Post page to where the Discussion box is.
And now, simply uncheck the box that says Allow comments. That’s all.
See the screenshot below.
If you can’t see the Discussion box, specially on Add New Page, go to the top of the screen, and click on Screen Options to open it.
You can now select Discussion to have it available on your Add New Page. See the screenshot image below.
Once available, you can uncheck the box Allow comments.
Go over to Discussion from the admin Dashboard, Settings > Discussion.
There are several options here to hide WordPress comments, these are labeled on the following screenshot.
For Option 2, simply uncheck the box, Allow people to post comments on new articles.
There are 2 issues to this option –
- this will apply only to ‘new’ articles, not those which you may have already written, and
- this can be overridden in individual post or page as covered under Option 1.
This option is interesting.
Here you check the box, Automatically close comments on articles older than, and mention the figure for days as zero (meaning 0 days).
What this will do is not only completely hide WordPress comments section on posts and pages, it will also eliminate and remove all previously posted comments as well.
A clever option could be to check the box, Users must be registered and logged in to comment.
This will stop non-subscribers to submit comments. But, the comments section remains visible to all.
There are other restrictions that can be imposed on the non-logged-in users for commenting, but they can still see the comments submitted by the subscribers.
As you can see, none of the options above meets my double criteria, which are –
- show WordPress comments to subscribers and logged-in users, and allow them to write comments and take part in discussions.
- completely hide WordPress comments section from non-logged-in users and non-subscribers, so that they simply don’t know that comments section exists.
To do this you have to do a bit of simple coding to selectively hide WordPress comments from non-logged-in users and non-subscribers just as I’ve done in this website.
Completely hide WordPress comments to non-subscribers
Follow the steps below to hide WordPress comments from non-subscribers but show it to subscribers or logged-in users.