wp insert post - get_page_by_title() not working as expected

I'm looping through an API with jobs and creating new posts from it like this:fetch jobs and loop through them...

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745579692a4634179.html

相关推荐

  • wp insert post - get_page_by_title() not working as expected

    I'm looping through an API with jobs and creating new posts from it like this:fetch jobs and loop through them...

    11小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信