admin管理员组文章数量:1023018
I'm looping through an API with jobs and creating new posts from it like this:
//fetch jobs and loop through them...
// check if post title exists, if not add it.
if ( ! get_page_by_title(html_entity_decode( $post_title ), OBJECT, 'jobs')) :
// create new post
$post_id = wp_insert_post( $my_post );
// set post terms
wp_set_post_terms( $post_id, $tags);
// create tweets through webhook via zapier
$tweet = 'webhook content here';
wp_remote_post( $tweet );
endif;
This works well for the posts, but for some reason if I'm looping through a 100 jobs, each time a 100 tweets are created and I don't understand why because it's not creating a 100 new posts with the same title.
How do I call the webhook if it's a new job that hasn't been added yet?
I'm looping through an API with jobs and creating new posts from it like this:
//fetch jobs and loop through them...
// check if post title exists, if not add it.
if ( ! get_page_by_title(html_entity_decode( $post_title ), OBJECT, 'jobs')) :
// create new post
$post_id = wp_insert_post( $my_post );
// set post terms
wp_set_post_terms( $post_id, $tags);
// create tweets through webhook via zapier
$tweet = 'webhook content here';
wp_remote_post( $tweet );
endif;
This works well for the posts, but for some reason if I'm looping through a 100 jobs, each time a 100 tweets are created and I don't understand why because it's not creating a 100 new posts with the same title.
How do I call the webhook if it's a new job that hasn't been added yet?
本文标签: wp insert postgetpagebytitle() not working as expected
版权声明:本文标题:wp insert post - get_page_by_title() not working as expected 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745579691a2157234.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论