首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vimeo api到wordpress帖子

Vimeo api到wordpress帖子
EN

Stack Overflow用户
提问于 2020-02-14 15:31:16
回答 1查看 113关注 0票数 2

我已经列出了使用vimeo api使用php的频道的vimeo视频,现在我想将所有的视频作为帖子上传到wordpress自定义postype,该怎么做?每次发布新视频时,我都应该将视频作为帖子添加到自定义postype中

EN

回答 1

Stack Overflow用户

发布于 2020-02-14 16:36:23

要在WordPress中创建帖子,可以使用以下代码。

Step1:

查找Vimeo webhooks选项,它将让您知道何时发布新的Vimeo视频。通过这样做,您可以获得视频的详细信息,然后使用该信息在WordPress中创建帖子。

Zapier Vimeo集成链接: https://zapier.com/apps/vimeo/integrations/webhook

Step2:

代码语言:javascript
复制
/**
 * A function used to programmatically create a post in WordPress. The slug, author ID, and title
 * are defined within the context of the function.
 *
 * @returns -1 if the post was never created, -2 if a post with the same title exists, or the ID
 *          of the post if successful.
 */
function programmatically_create_post() {

    // Initialize the page ID to -1. This indicates no action has been taken.
    $post_id = -1;

    // Setup the author, slug, and title for the post
    $author_id = 1;
    $slug = 'example-post';
    $title = 'My Example Post';

    // If the page doesn't already exist, then create it
    if( null == get_page_by_title( $title ) ) {

        // Set the post ID so that we know the post was created successfully
        $post_id = wp_insert_post(
            array(
                'comment_status'    =>  'closed',
                'ping_status'       =>  'closed',
                'post_author'       =>  $author_id,
                'post_name'     =>  $slug,
                'post_title'        =>  $title,
                'post_status'       =>  'publish',
                'post_type'     =>  'post'
            )
        );

    // Otherwise, we'll stop
    } else {

            // Arbitrarily use -2 to indicate that the page with the title already exists
            $post_id = -2;

    } // end if

} // end programmatically_create_post
add_filter( 'after_setup_theme', 'programmatically_create_post' );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60221813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档