set_post_type
函数
set_post_type ( $post_id = 0, $post_type = 'post' )
- 参数
-
-
(int)
$post_id
Optional. Post ID to change post type. Default 0.- Required: 否
-
(string)
$post_type
Optional. Post type. Accepts ‘post’ or ‘page’ to name a few. Default ‘post’.- Required: 否
- Default: ‘post’
-
(int)
- 返回值
-
- (int|false) Amount of rows changed. Should be 1 for success and 0 for failure.
- 定义位置
-
-
wp-includes/post.php
, line 2220
-
wp-includes/post.php
- 引入
- 2.5.0
- 弃用
- –
更新帖子ID的文章类型。
页面或文章的缓存将为文章ID进行净化。
function set_post_type( $post_id = 0, $post_type = 'post' ) { global $wpdb; $post_type = sanitize_post_field( 'post_type', $post_type, $post_id, 'db' ); $return = $wpdb->update( $wpdb->posts, array( 'post_type' => $post_type ), array( 'ID' => $post_id ) ); clean_post_cache( $post_id ); return $return; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。