1

I created a custom post type. Plugin used is Custom Post Types & Custom Taxonomies plugin which does the job very good.

And added some posts to it.

But when I modify the name of the newly created custom post type, the posts no more show.

I tried a plugin called pTypeConverter but I wish I didn't. It's outdated & not even getting deleted.

What I finally did is this query:

UPDATE `wp_posts`
SET 
    `post_type` = REPLACE(`post_type`,'custompost1','student-portal'),
    `guid` = REPLACE(`guid`,'<from old url>','<to new url>')
WHERE `post_type` = 'custompost1'

Now the posts show at the new post type but all the Metabox galleries I created with MetaBox.io aren't visible any more in the new custom post type.

Why doesn't WordPress follow the id as foreign key for example, why the name? And what to do to retrieve all posts as they already were but with the new custom post type (alongside their Meta Boxes).

1
  • There's probably some data still referencing the old cpt name custompost1. Your can try searching the DB for custompost1 for clues. This isn't a WordPress core thing, it sounds like it's something specific to the MetaBox.io plugin. Please try using the support channels offered by that plugin, as third party plugins are not supported here at WPSE. Commented Jun 24, 2022 at 17:58

1 Answer 1

3

I think what you're saying is that you're changing the name of the posttype (CPT) itself not the posts within that post type.

If that IS the case then WordPress is performing exactly as it should. That plugin is creating a CPT "custompost1" and then you are adding posts (1,2,3,etc) with that post type.

Then you instructed the plugin to no longer show the post type "custompost1" when you changed it to "student-portal". That plugin isn't also changing all the actual posts you created. It's simply telling WordPress that the old post type is no longer valid (as it's no longer referencing it) but the new one what should be used.

You can do this in a couple ways, but the easiest for you would be to tell the plugin to create both CPTs (temporarily). Then get another plugin that changes posts from one type to another. There are many of these plugins (search post type switcher in the repository).

Now open the original posts "custompost1" list, select all of them in the admin section and simply change them to "student-portal" CPT.

After that is complete you should see all the posts now under the "student-portal" CPT list.

All that's left is to delete the post type switcher plugin and then remove the CPT "custompost1" from the plugin you used to create it.

UPDATE

To edit all posts you can click the check box above all of the posts in the column header (pic attached).

Then choose Bulk edit right above that(just above the red circle in my photo), then click apply. just below that an options panel will open. You can choose the post type there and then click apply.enter image description here

If you have more than 20 posts, go to screen options in the top right and you'll see an option to show more than 20 posts per page. Do this before you change them all and you can do it in one shot.

3
  • Thanks rudtek, for mentioning post type switcher which does the job. Can you please explain or rephrase your following sentence as I didn't understand it: "Now open the original posts "custompost1" list, select all of them in the admin section and simply change them to "student-portal" CPT." With a plugin such as Post Type Switcher there doesn't seem an option to select all posts but must edit each post.
    – compliance
    Commented Jun 14, 2022 at 10:13
  • @compliance. I updated my question
    – rudtek
    Commented Jun 14, 2022 at 15:17
  • 1
    Thanks man. Good to have people like you.
    – compliance
    Commented Jun 16, 2022 at 7:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.