Disable all comments and pingbacks
Many installations get comment spam via default open comments via media attachment pages and/or old posts etc.
Default setting is often changed later but existing comments stay open. Especially for media it is pita to disable open comments and pingbacks.
We use direct SQL in most cases, similar as described here.
Maybe you want to add a function which closes all comment_status
and ping_status
or sets to current default setting or similar.
This is the source code.
function comments_open( $post_id = null ) {
$_post = get_post( $post_id );
$post_id = $_post ? $_post->ID : 0;
$open = ( 'open' == $_post->comment_status ); // line 1243
There is only one error occurring, no other errors.
How can I fix this?
When I look at the DB, I see that comment_status has actually been set to ‘closed’ on every record. To reenable commenting, I run the following SQL command:
UPDATE wp_posts p SET comment_status = ‘open’ WHERE comment_status = ‘closed’;
Some time later, it could be a week, a month, or two days, the comment status will be changed to ‘closed’ again on every record. I have not been able to figure out what keeps causing this recurring problem. What action has the side-effect of touching the comment-status field on every post in the DB?
Looking around on the forums, I see a number of posts that appear to be describing the same problem, but none with a resolution. If this problem is indeed this ubiquitous, I assume someone must have discovered the root cause.
Can anyone help?
Thanks.
]]>Why?
FWIW, I don’t auto-expire posts because it also auto-expires pages so I run a batch job to expires posts (and not pages) that are older than x days. Re-running the batch job fixed this but only after getting buried in spam.
It would be good to separate the auto-expiration of posts from pages.
]]>I’ve created a custom post type where the ‘supports’ argument includes ‘comments’. however, the comment form is not showing on posts of this type. When I echo $post->comment_status, it returns ‘closed’, but if I look at the database row for the post in question, the comment_status field is set to ‘open’..
Also, I tried commenting the
if ($post->comment_status == 'open') : ?>
check in my comments.php file, but then if you submit a comment it is refused, saying comments are closed on the post.
I find this very curious, as you can imagine..
(commenting in general is allowed in the settings, as well as comments on the posts themselves)
won’t you please help me
]]>This problem occurs with every theme I tried to locate the problem.
Anyone have an idea?
Maiskolben
]]>I am using WP 3.0.1 and a child theme (css and header changes) of Twenty ten.
I moved a site from b2evolution and it immediately began attracting comment spam ON ITS IMAGES only. It would almost appear that some spammers know that WP offers commenting on images that can’t be turned off, or is hard to turn off!
I’ve installed some anti-spam plugins, which (I hope) will reduce spam comments on images. But I don’t care to offer ANY commenting opportunity on images at all (as apart from the postings into which they are embedded). And, to reiterate: turning off comments on the post does NOT turn off comments on the image.
I’m hoping somebody knows a trick here that will turn off image comments.
]]>I’m developing my first plugin which changes some functionality using the comments_open hook. No problems there, worked great on my local install.
However, I tried it on a live 2.8 site and it didn’t work, in this case because the theme didn’t use comments_open()
Instead the theme used ('open' == $post-> comment_status)
which as far as I can tell does exactly the same thing, but without allowing plugins to hook in. I’m guessing this was a nice up-to-date 2.8 site but using an older theme.
So my question is…
Is this anything to worry about when releasing a plugin? I managed to get this site working by changing the theme to use comments_open()
, but I was wondering if there was a way I could hook into $post-> comment_status directly as well, just to make sure the plugin works. Is this a case of it being the site-owners job to upgrade their theme or is there something I can do as the plugin developer to make their job easier?
Any feedback appreciated.
Harvey.
]]>