set_post_type from filosofo. fixes #4844
git-svn-id: https://develop.svn.wordpress.org/trunk@6537 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c4b97ae9e3
commit
5a9f249b34
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue