WordPress发送到pingback服务函数:do_all_pings
WordPress函数do_all_pings()执行所有pingbacks、enclosures、trackbacks和发送到pingback服务的操作。该函数通常用于在发布新文章后,自动通知其他网站或服务,以便它们可以抓取和索引新内容。
函数参数
该函数不接受任何参数。
函数返回值
该函数没有返回值。
函数使用示例
在文章发布后手动触发ping操作:
function custom_publish_post($post_id) {
// 发布文章的代码...
// 手动触发ping操作
do_all_pings();
}
add_action('my_custom_publish_event', 'custom_publish_post');
在特定条件下延迟触发ping操作,可以使用wp_schedule_single_event()函数来安排do_all_pings()的执行:
function custom_publish_post($post_id) {
// 发布文章的代码...
// 延迟10分钟后触发ping操作
wp_schedule_single_event(time() + 600, 'custom_do_all_pings');
}
add_action('my_custom_publish_event', 'custom_publish_post');
function custom_do_all_pings() {
do_all_pings();
}
add_action('custom_do_all_pings', 'custom_do_all_pings');
扩展阅读
do_all_pings()函数位于:wp-includes/comment.php
相关函数:
- do_action()