在wordpress創建新博客帖子時,所有帖子細節都需要發送給第三方api。我使用save_post掛鉤這一點,但不知道是否它獲取調用或不 這是我到目前爲止保存帖子時不會調用save_post鉤子
add_action('save_post', 'new_blog_details_send');
function new_blog_details_send($post_id) {
//getting blog post details//
$blog_title = get_the_title($post_id);
$blog_link = get_permalink($post_id);
$blog_text = get_post_field('post_content', $post_id);
///Sending data to portal////
$post_url = 'http://example.com/blog_update';
$body = array(
'blog_title' => $blog_title,
'blog_link' => $blog_link,
'blog_text' => $blog_text
);
//error_log($body);
$request = new WP_Http();
$response = $request->post($post_url, array('body' => $body));
}
不知道如何登錄或調試在wordpress.Any幫助將是完成appericiated提前致謝
你檢查你的第三方是否使用靜態內容的工作? – sarath
是的,它工作正常 –
此代碼在functions.php中添加對不對?如果您在本地服務器中,則打印$響應並退出。然後通過保存帖子進行檢查。 – sarath