Support Forum
Support › MB Custom Post Type › 'A post type mismatch has been detected.' error when saving custom post type
When saving a post for a custom post type, I'm getting an 'A post type mismatch has been detected.' error that seems to be originating from Meta Box.
What might be the issue here?
Hello,
I'm not sure what causes the issue on your site, you can try to deactivate all plugins except Meta Box, MB extensions, and switch to a standard theme of WordPress to see if it helps.
You can also follow this article to fix this issue https://wordpress.org/support/topic/cannot-add-new-page-or-post-corrupted-db/
I debugged the issue (on a fresh WP install, default theme, only MB installed) and narrowed it down to a single Meta Box custom field. I have a custom field that has an id of 'post_type' and that seems to cause the error. When I change the field id to any other name, then the post saves fine. Seems like a possible bug. You can try to replicate it on your end.
Here is the code for the custom field:
'name' => __('Post Type', 'api-manager'),
'id' => $prefix . 'post_type',
'type' => 'select_advanced',
'desc' => __('Select the post type associated with the custom field you are mapping the data to.', 'api-manager'),
'options' => [
'Populate with the available post types' => __('Populate with the available post types', 'api-manager'),
],
'placeholder' => __('Select a post type.', 'api-manager'),
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'Post types in WordPress distinguish between various kinds of posts. To correctly associate the custom field, select the post type it corresponds to.',
],
'visible' => [
'when' => [['object_type', '=', 'post']],
'relation' => 'or',
],
'tab' => 'data_storage_tab',
Hello,
It could be an issue when you use the field ID as one of the reserved terms of WordPress, please check them here https://codex.wordpress.org/Reserved_Terms
You can add the prefix with your own value to fix this issue.