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).
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.
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.
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.