set_post_type from filosofo. fixes #4844

git-svn-id: http://svn.automattic.com/wordpress/trunk@6537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-01-02 20:06:00 +00:00
parent 28e6daf192
commit 0bc86efb8c
1 changed files with 30 additions and 0 deletions

View File

@ -288,6 +288,36 @@ function get_post_type($post = false) {
return false; return false;
} }
/**
* set_post_type() - Set post type
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @subpackage Post
* @since 2.4
*
* @uses $wpdb
* @uses $posts {@internal Missing Description}}
*
* @param mixed $post_id post ID
* @param mixed post type
* @return bool {@internal Missing Description}}
*/
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->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE ID = %d", $post_type, $post_id) );
if ( 'page' == $post_type )
clean_page_cache($post_id);
else
clean_post_cache($post_id);
return $return;
}
/** /**
* get_posts() - Returns a number of posts * get_posts() - Returns a number of posts
* *