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
Related Posts:
- Custom post type and taxonomy – show related posts
- How to get all taxonomies of a post type?
- Permalinks: custom post type -> custom taxonomy -> post
- How to Add Tags to Custom Post Type?
- Efficient Taxonomy Intersection
- Set relationship between custom_post_types
- Remove admin menu for custom taxonomy attached to custom post type
- How do I list custom taxonomy terms without the links?
- Page not found taxonomy custom post type
- How to list custom taxonomy categories?
- clients list using wordpress
- Custom taxonomy query for a custom post type
- Extend walker class with custom post types [closed]
- How to do a custom bookmarks post type?
- Add taxonomy to already registered custom post type
- Custom Metabox with Taxonomy Dropdown – Saving Issue
- Custom Post Type / Taxonomy Slug / Post Title with post type archive
- Term Checklist Walker – Disable Parent Categories
- Show certain terms from custom taxonomy but exclude ‘parent’ terms?
- Pagination throws 404
- Limiting number of custom posts shown on taxonomy page
- Custom Taxonomy conditionals
- Include custom post type in “all posts”
- Help with issues on “Adding a Taxonomy Filter to Admin List for a Custom Post Type?”
- How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to create archive page for taxonomy terms within custom post type
- Category and post tag archives do not include posts from custom post type
- How do I provide a “show all posts” link in a paginated term archive?
- List terms from Custom Taxonomy
- Can I change the slug of my archive page on a Custom post type?
- Automatically populate a hierarchical taxonomy from a custom field
- Set object terms not working on plugin activation
- Display only post types that are direct children of the current taxonomy
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- custom taxonomy relationship
- Parent & Child Taxonomy slugs in custom post permalink
- Custom Taxonomy Invalid in REST API
- How to use the post_title of custom post type as taxonomy
- Custom Post Type Archive Page Filtering
- Custom Post Type With Categories
- Missing Posts in Custom Taxonomy List
- Custom Taxonomy Doesn’t Show Up
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- browse by category and tags?
- Taxonomy structure help
- Create more category hierarchical depth for custom post type/taxonomy plugin (widget)
- How do I share categories across multiple post types?
- Migrating a taxonomy’s tags to the native category
- Show custom post type inside a custom post type
- How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data
- How to check if post/page or taxonomy post is published by admin
- Custom taxonomy or custom page templates?
- Permalink problems with custom post type and custom taxonomy
- Get terms of a post but only if they’re also the child of a specific term
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- Custom order of Taxonomy Terms
- Custom Post Type Advanced Slug
- filter by custom taxonomy using ajax
- tax_query (if the terms are empty)
- Getting only one post per category
- Should putting custom code in functions.php or created the plugins [duplicate]
- Page listing all categories for CPT
- Get posts by category name
- List child categories from parent category on custom taxonomy page
- Grab all Custom Posts by multiple taxonomies and terms
- Create a custom taxonomy template that loops through child categories in term order?
- Custom Post Types and Complex Content Hierarchy
- If custom taxonomy else conditional [closed]
- How to implement very unusual wordpress routing structure?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- How to display custom taxonomy term specific post?
- Changing permalink of default Post with custom post
- get_queried_object not work in taxonomy page
- wp_insert_post deleting previous post custom meta
- Change custom post taxonomy values from front-end
- Pages of my taxonomy terms are showing all posts
- How to create a permalink structure with custom taxonomies and custom post types
- Is there a way to re-order the Custom Taxonomy drop-down on a Custom Post listing page?
- How to get all posts related to a taxonomy?
- Custom post types not displaying per category
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Force WordPress to only match URL in category
- Hierarchical taxonomy in permalink structure
- Can I create a taxonomy term that mirrors the name of a new custom post?
- Rewrite for custom type and custom taxonomy
- How to create TEMPLATES for TAXONOMIES? What I have to change in this code?
- Custom Post Status & Taxonomies
- predefined custom field on registration page
- Displaying taxonomy icon outside archive page
- Why won’t this rewrite rule work?
- Archive.php is not displaying tags
- How to not have the items of the subtaxonomy within the parent taxonomy
- How to save an integer as taxonomy term?
- Sort custom post type items by taxonomy description
- Tags and Taxonomy links not working for Custom Post Types
- Get custom post type parent category
- How can i change url structure of cpt like this?