📜  wordpress 以编程方式添加注释 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:05.940000             🧑  作者: Mango

代码示例1
$agent = $_SERVER['HTTP_USER_AGENT'];
$data = [
    'comment_post_ID' => 19,
    'comment_author' => 'Dave',
    'comment_author_email' => 'dave@domain.com',
    'comment_author_url' => 'http://www.someiste.com',
    'comment_content' => 'Lorem ipsum dolor sit amet...',
    'comment_author_IP' => '127.3.1.1',
    'comment_agent' => $agent,
    'comment_type' => '',
    'comment_date' => date('Y-m-d H:i:s'),
    'comment_date_gmt' => date('Y-m-d H:i:s'),
    'comment_approved' => 1,
    'comment_parent' => 2,    //add field if this comment is a reply
];
$comment_id = wp_insert_comment($data);