我有一个“真正的”cron作业,它执行wp cron。php时不时。我通过$link=get\\u edit\\u post\\u link(ID)将链接收集到变量中;
如果我登录并使用wp cron手动执行cron,它就会完美地工作。php,但当它按计划执行时,它不会收集链接并将其保留为空。代码的分条版本:
foreach($published_posts as $post_to_private){
$user_data = get_userdata( $post_to_private->post_author);
$email = $user_data->user_email;
$link = get_edit_post_link( $post_to_private->ID);
$email = WP_Mail::init()
->to($email)
"X-Mailer: PHP/". phpversion(),
"Content-type: text/html; charset=utf-8",
])
->subject(\'test\')
->template(plugin_dir_path( __DIR__ ) .\'email-templates/expired-transit-email.php\', [
\'link\' => $link,
]);
//for testing of email
return $email->send();
有什么想法吗?