WordPress根据文章ID设置文章类型函数:set_post_type

WordPress函数set_post_type为指定ID的文章设置文章类型。

set_post_type( int $post_id, string $post_type = 'post' )

函数参数

$post_id

整数

要修改的文章ID

$post_type

字符串

文章类型

函数使用示例

$post_id = 3546;
 
if ( set_post_type( $post_id, 'page'  ) ) {
	echo "文章{$post_id}的类型现在为page";
} else {
	echo '无法将文章转换为page';
}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » WordPress根据文章ID设置文章类型函数:set_post_type