最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • WordPress函数wp_get_post_revisions()用法 获取文章修订版本信息

    正文概述 知事网   2020-09-11 09:09:11   366

    描述:

    获取一篇文章的所有修订版本信息

    用法:

    <?php wp_get_post_revisions( $post_id, $args ); ?>

    参数:

    $post_id

    (mixed) (必填) 文章ID

    默认值: 0

    $args

    (array) (可选) 查询条件

    默认值: None

    有关参数$args接受的参数列表,请参阅WP_Query文档的parameters部分。

    源文件:

    /**
    * Returns all revisions of specified post.
    *
    * @since 2.6.0
    *
    * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    * @return array An array of revisions, or an empty array if none.
    */
    function wp_get_post_revisions( $post_id = 0, $args = null ) {
    $post = get_post( $post_id );
    if ( ! $post || empty( $post->ID ) )
    return array();
    
    $defaults = array( 'order' => 'DESC', 'orderby' => 'date ID', 'check_enabled' => true );
    $args = wp_parse_args( $args, $defaults );
    
    if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) )
    return array();
    
    $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );
    
    if ( ! $revisions = get_children( $args ) )
    return array();
    
    return $revisions;
    }

    知事网 » WordPress函数wp_get_post_revisions()用法 获取文章修订版本信息

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元