为了实现自动评论并随机指定的评论内容,您可以编写自定义插件或在主题中添加以下代码:
function auto_comment($id) { // 填写您的评论内容模板 $comments = array( '这篇文章写得非常好,我收获了很多。', '我一直在寻找这样的信息,非常感谢您。', '非常详细的教程,谢谢您的分享。', '非常感谢您提供这些信息,我会分享给我的朋友们。', '您写得非常清晰明了,我非常感谢您。' ); // 选择一个随机评论内容 $comment = $comments[array_rand($comments)]; // 随机延迟时间 $delay = rand(1, 300); // 添加评论 $data = array( 'comment_post_ID' => $id, 'comment_content' => $comment, 'comment_author' => '自动评论', 'comment_author_email' => 'email@example.com', 'comment_author_url' => 'https://example.com', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0, 'comment_author_IP' => '', 'comment_agent' => '', 'comment_date' => date('Y-m-d H:i:s', time() + $delay), 'comment_approved' => 1, ); wp_insert_comment($data); } // 添加评论钩子 add_action('publish_post', 'auto_comment');
上述代码将在发布帖子时自动触发,并随机选择一条评论内容。请注意,上述代码只是示例,您需要根据自己的需要进行修改和配置。另外,自动评论可能会被视为垃圾评论,并导致您的站点被惩罚,因此请谨慎使用。