0

I want to allow comments only for custom post types but not for normal posts or pages. What would be the best way to do that? I can think of one way that is a bit ugly.

One would be to remove the comment section from the post/page template in my child theme and then have the option under "Discussion" active.

I could hide the comments one posts and pages through CSS, but that wouldn't necessary prevent comments from being posted (even though they would be hidden on the frontend).

Is there a way to just remove the comment support for posts but keep it for custom post types? I also tried it like mentioned here: Is there ANY way to remove comments function and section totally?

But it doesn't hide the comment section underneath the post, if it's already active. Also wouldn't any new post have the comment section activated, if I have the option under "Discussion" active?

1 Answer 1

0

if you are using the code from the thread you linked to, to disable the comments on post and pages then when a new post/page is added it should have the comments automatically disabled.

The existing posts/pages will have comments enabled unless you uncheck the "Allow comments" checkbox when editing a post.

A quick and dirty way to disable comments for all posts is to run the below MySQL query from phpMyAdmin

UPDATE wp_posts SET comment_status = 'closed' WHERE post_type = "post"

You can also go to wp-admin / Posts panel, check all the posts, in "Bulk Action" select "Edit" and press "Apply", additional options will show, now in the "Comments" field select "Do not allow" and click "Update" button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.