Copy one CPT to another one in WordPress

You can update a posts type using wp_update_post:

$my_post = array(
    'ID'        => $post_id,
    'post_type' => 'winner',
);
wp_update_post( $my_post, true );

// check if it failed and tell the user why
if ( is_wp_error( $post_id ) ) {
    $errors = $post_id->get_error_messages();
    foreach ( $errors as $error ) {
        echo 'error: '.esc_html( $error );
    }
}

Where $post_id is the ID of the post you’re switching to

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)