• Resolved robert460

    (@robert460)


    Hello,

    First of all: many thanks for this great plugin.

    I had a look on the forum and in the documentation to see how I can “register” an already existing custom post type (named services) in the Custom Post Type UI plugin.

    I installed the plugin and the already existing services CPT (which was created by an external developer in code, not with any plugin) is not listed as already existing CPT in the plugin, which is probably normal. However, how can I make sure it will be editable via the Custom Post Type UI plugin?

    FYI: I am not importing or exporting from or to any other website. I installed the plugin on my website and on it there was already an existing CPT “Services”, for which I would like to be editable via the plugin, if possible.

    Many thanks for your help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi @robert460

    It’s largely a protective measure just to make sure that the same post type isn’t registered in multiple places at the same time, leading to odd results. The way post types and taxonomies work is that they’re registered on the fly every page load, and registering the same post type in multiple places, has whichever was registered last, being the one used.

    So, in terms of moving things in to CPTUI from code, I’d say it’s best to match up the settings/configuration as best possible, fill in the fields, and configuration etc, and use a slightly alternate slug momentarily. If your slug is “named_services” perhaps do “named_servicess”. Don’t publish any posts just yet, but get this slight alteration saved.

    Then once ready, remove the original post type registration code and save the file that was registering it.

    Once that’s done, you can go back to CPTUI to rename the slug to what you want it to be, and hit save there. It should all be pretty seamless and you’ll have things migrated into CPTUI afterwards.

    Hi, thanks for your answer, I’m with the same problem than @robert460 . I was thinking if deleting the theme CPT call, I can create it in the plugin and it will work, knowing which name and taxonomy have, is that possible?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @deimidis You mean CPTUI showing you already registered content types in some way?

    Your admin menu would likely do that for you already, though it won’t be as quick in cases where a page has the same slug.

    That said, thanks to this forum thread, we are looking into adding in the ability to save a content type despite a matching slug, by way of a checkbox that will tell us “we’re trying to migrate a content type to CPTUI”. It’ll be going under the assumption that the other registering code would be getting removed.

    Yes, I was saying a way to import a CPT that resides in a theme functions.php, because there are other plugins that use CPTUI to show CPT in blocks. Anyway, I made it work taking out the CPT from the theme folder, and rebuild it on CPTUI, and then it was recognized by other plugins.

    Thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Awesome to hear you have what you need working.

    “Then once ready, remove the original post type registration code and save the file that was registering it.”

    I don’t understand what this means. How do I find the “original post type registration code“, and where do I find the “file that was registering it”? I think your solution is what I’m looking for, but I’m not familiar enough with post types to understand what to do. Thanks.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @steve31266 if you’re using a different plugin like ACF or Pods, or similar, you’d just need to delete the registration from their settings.

    Otherwise, if you manually registered the post type yourself, go back to where you added the register_post_type() call and remove there. It’s impossible for us to know for sure where any of this happened for you, but a common place could be your functions.php file in your active theme.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How register existing CPT in plugin’ is closed to new replies.