我正在开发一个 Wordpress 插件,它采用PitchEngine JSON 提要,并将每个“Pitch”添加为 Wordpress 帖子。
我能够检索“音高”内容,但是将“音高”添加为帖子的波纹管功能会导致无限循环,从而添加无限数量的帖子。我已经将其追溯到 wp_insert_post 函数。没有它,就没有无限循环,有了它,就有...
function pitchengine_create_post($jsonvals, $post_type = 'post') {
//Create Post
$post = array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_content' => $jsonvals->Text,
'post_date' => $jsonvals->PublishDate,
'post_excerpt' => $jsonvals->Summary,
'post_status' => 'publish',
'post_title' => $jsonvals->Headline,
'post_type' => $post_type,
);
$post_id = wp_insert_post( $post, $wp_error );
//Add Post Meta
//pitchengine ID [DisplayUrl]
add_post_meta($post_id, 'pitch_ID', $jsonvals->DisplayUrl);
//pitchengine URL (brand Url base) + [DisplayUrl]
add_post_meta($post_id, 'pitch_URL', $jsonvals->Meta->shorturl);
//source name (pitchengine)
add_post_meta($post_id, 'pitch_name', 'Pitch Engine');
//If error, return error
//If success set return post ID
$response = $post_id;
return $response;
}
有什么想法我可能会出错吗?