wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



set_post_type › WordPress Function

Desde2.5.0
Obsoleton/a
set_post_type ( $post_id = 0, $post_type = 'post' )
Parâmetros: (2)
  • (int) $post_id Optional. Post ID to change post type. Default 0.
    Required: No
    Padrão:
  • (string) $post_type Optional. Post type. Accepts 'post' or 'page' to name a few. Default 'post'.
    Required: No
    Padrão: 'post'
Retorna:
  • (int|false) Amount of rows changed. Should be 1 for success and 0 for failure.
Definido em:
Codex:

Updates the post type for the post ID.

The page or post cache will be cleaned for the post ID.


Fonte

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->update( $wpdb->posts, array( 'post_type' => $post_type ), array( 'ID' => $post_id ) );

	clean_post_cache( $post_id );

	return $return;
}