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?