最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp insert post - get_page_by_title() not working as expected

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论