Support » Fixing WordPress » How to change a post type into another post type?

  • mattmikulla

    (@mattmikulla)


    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • vtxyzzy

    (@vtxyzzy)

    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'
    mattmikulla

    (@mattmikulla)

    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.

    vtxyzzy

    (@vtxyzzy)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change a post type into another post type?’ is closed to new replies.