作者广告
作者广告

WordPress实现自动评论帖子,并随机指定的评论内容

为了实现自动评论并随机指定的评论内容,您可以编写自定义插件或在主题中添加以下代码:

 

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');

上述代码将在发布帖子时自动触发,并随机选择一条评论内容。请注意,上述代码只是示例,您需要根据自己的需要进行修改和配置。另外,自动评论可能会被视为垃圾评论,并导致您的站点被惩罚,因此请谨慎使用。

该文章已被以下专题收入

给TA打赏
共{{data.count}}人
人已打赏
[elementor-template id="106011"]
网站运营

更改WordPress后台用户按照注册时间倒序显示

2023-4-25 13:51:13

开发与运维网站运营

Chatgpt私有化部署教程,搭建自己的ChatGPT平台

2023-5-22 15:38:14

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索