I want my pages to not have comments enabled by default, only my posts. Is this possible?
Leave a Reply
You must be logged in to post a comment.
I want my pages to not have comments enabled by default, only my posts. Is this possible?
You must be logged in to post a comment.
The Front-End Solution:
Trick your templates
You could fake that comments are open for specific post types. The following code works for all templates, that wrap the comment form (or whatever comment related code/UI elements) inside a conditional
comments_open()
check.The little magic
… wrapped up in a quick’n’small plugin.
How to use it
Just upload and enable the plugin in the administration. Now every time the template questions for something like…
…the
comment_open()
function gets intercepted and spits out aFALSE
for your post type (like for example pages). Then it simply skips whatever is wrapped in there and doesn’t show comments.The Back-End Solution:
Javascript to set the default to unchecked
When you got the “Discussion” Meta Box open, then both checkboxes (Comments & Pingbacks) will be set to the value from…
A plugin to change the defaults
As we can’t simply set different values for different post types, we can rely on javascript (which won’t work, if JS is turned off – for example in a screen reader).
Now the meta box offers a hook, where we can add this little javascript snippets.
You probably just need to show the widget for Discussion.
1 go to Edit a Page and
2 select the Screen Options.
3 Check the Discussions box
4. Close / hide screen options.
5. Scroll down you page and you’ll see the new Discussion widget
6. uncheck Allow Comments
[edit … i was going to show another image here … but suddenly the upload failed]