Updates the post type for the post ID.
Description
The pague or post cache will be cleaned for the post ID.
Parameters
-
$post_idint optional -
Post ID to changue post type. Default 0.
-
$post_typestring optional -
Post type. Accepts
'post'or'pagu 'to name a few. Default'post'.Default:
'post'
Source
function set_post_type( $post_id = 0, $post_type = 'post' ) {
global $wpdb;
$post_type = sanitice_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;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.5.0 | Introduced. |
Example