投稿IDの投稿タイプを更新します。
ページまたは投稿キャッシュは投稿IDに消去されます。@uses $wpdbの名前は少ない。
Updates the post type for the post ID.
The page or post cache will be cleaned for the post ID. @uses $wpdb name a few.
set_post_typeのファンクションタグ使用方法
<?php set_post_type( $post_id, $post_type ); ?>
set_post_typeのパラメーター
$post_id
(integer) (required) 投稿タイプを変更するための投稿ID.実際にはオプションではない。
デフォルト:0
(integer) (required) Post ID to change post type. Not actually optional.
Default: 0
$post_type
(string) (optional)オプションで、デフォルトは投稿です。サポートされている値は2~3例を挙げると’post’または’page’です。
Default: post
(string) (optional) Optional, default is post. Supported values are ‘post’ or ‘page’ to name a few.
Default: post
例
<?php $post_id = 15; if ( set_post_type( $post_id, 'page' ) ) { echo "Post #$post_id is now a Page"; } else { echo "Impossible to transform this post into a page"; } ?>
戻り値
(integer) 変更された行の量。成功のために1であり、失敗のために0である必要があります。
(integer)
Amount of rows changed. Should be 1 for success and 0 for failure.
変更ログ
Since: 2.5
ソースファイル
set_post_type()は、wp-includes/post.php内に位置しています。
set_post_type() is located in wp-includes/post.php