WordPress.org

Ready to get started?Download WordPress

Forums

How to change a post type into another post type? (4 posts)

  1. mattmikulla
    Member
    Posted 3 years ago #

    I have a custom post type of art but I now want to create a post type for individual mediums of art. Photography, Drawing, Ceramics, etc.

    Is there a way to select an individual post with a custom post type art and turn it to a new post type I have created, Photography for example.

    Originally I had on generic post type of art and had the medium (Photography, Ceramics, etc) as a taxonomy. However, I would rather my photos, ceramics, to have the url slug mysite.com/photography/... instead of mysite.com/art/...

    Any thoughts or ideas.

  2. vtxyzzy
    Member
    Posted 3 years ago #

    You can use phpMyAdmin to issue SQL updates to do this.

    BACK UP YOUR DATABASE FIRST!

    Create/register your new post types to get started. Then use a SQL command like that below to change each type:

    UPDATE wp_posts p
    JOIN wp_term_relationships tr ON (p.ID = tr.object_id)
    JOIN wp_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
    JOIN wp_terms t ON (tt.term_id = t.term_id)
    SET post_type = 'photography'
    WHERE p.post_type = 'art'
    AND p.post_status = 'publish'
    AND tt.taxonomy = 'category'
    AND t.name = 'Photography'
  3. mattmikulla
    Member
    Posted 3 years ago #

    Thanks.

    The problem is I have about 100 posts with the post type of art and they need to be broken down into several post type. Photography, Photo Illustration, and Illustration.

    Sorry I should have been more clear.

  4. vtxyzzy
    Member
    Posted 3 years ago #

    The SQL I gave will change the type from 'art' to 'photography' for those posts that are in the category 'Photography'.

    You would modify the 'SET post_type =' and the 'AND t.name =' statements for each type.

    If your taxonomy is not 'category', you will need to modify that also.

    You should be sure to register your new post types first.

Topic Closed

This topic has been closed to new replies.

About this Topic