From 5a9f249b34fa2d57dcae5c1b004725890f1b2d22 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 2 Jan 2008 20:06:00 +0000 Subject: [PATCH] set_post_type from filosofo. fixes #4844 git-svn-id: https://develop.svn.wordpress.org/trunk@6537 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wp-includes/post.php b/wp-includes/post.php index c0a97634a5..82f114a949 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -288,6 +288,36 @@ function get_post_type($post = 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 *