Skip Navigation

[Resolved] convert existing CPT to TYPES control

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1462913

I have read the thread and link within concerning:
https://toolset.com/faq/how-do-i-convert-existing-custom-types-and-fields-to-types-control/

As old themes that had custom post types (for portfolio and custom blog posts) became unsupported it will be more and more necessary to easily gain access to that data & it's slugs. I have 3 sites that need this at this time.

Has there been any improvements or new tools to do this since 2012 post I found?

Would this plug be a solution: Post Type Switcher

#1463317

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to have more description of your issue.

Do you mean that you have three sites where you want to convert the existing post types to Types plugin and you are not able to locate the post type slug which you actually wanted to convert to Types plugin?

#1464169

Not exactly - I was wondering if since the only description I've found of easily converting custom post types w/taxonomies hard coded into themes to toolset types CPT's is from 2012 - is their a more updated method of handling this than the post I found.

The plugin I mentioned 'Post Type Switcher' works fine so far, but there is no tool for associating the previous taxonomy from the 'theme' hard coded post type to the new toolset post type. The taxonomy can be re-created, then find/replace in the database, also I have no problem finding and re-associating custom fields from within 'Post Field Control' but as you can see from my explanation this is a fragmented and laborious way to handle this and I was really hoping TOOLSET did/will provide a conversion tool to completely re-associate a theme hard coded CPT and its taxonomies to a TOOLSET CPT. As you know once the theme is dis-associated from the site the CPT & it's taxonomies is gone from dashboard and you're left with the database data only (and media that was uploaded).

#1468667

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So, the possible solution could be that you should try to use the following filter to register your taxonomy once you convert your post type.


add_filter( 'wpcf_type', 'func_register_taxonomy_and_attach_to_posttype', 10, 2 );
function func_register_taxonomy_and_attach_to_posttype( $params, $post_type ) {
    // adjust to your needs
    $cpt_slug   = 'posttype-slug';  // replace posttype-slug with your original post type slug
    
  // add here your register taxonomy code and adjust the code accordingly and replace your taxonomy slug.
    $taxonomies_to_add = array( 'your-tax-slug' );
    // stop editing
    
    if( $post_type != $cpt_slug ) {
        return $params;
    }

    $params['taxonomies'] = isset( $params['taxonomies'] ) ? $params['taxonomies'] : array();

    if( is_array( $taxonomies_to_add ) ) {
        $params['taxonomies'] = array_merge( $params['taxonomies'], $taxonomies_to_add );
    } else {
        $params['taxonomies'][] = $taxonomies_to_add;
    }

    return $params;
}