Troubleshooting Ocean Extra Metabox Issues: Saving Problems and Custom Post Type Setup
Content
Many users of the Ocean Extra plugin encounter issues with its metabox functionality, particularly when working with custom post types or WooCommerce products. This guide covers the most common problems and their solutions, compiled from community reports and fixes.
Common Problem: Metabox Not Saving on WooCommerce Products
A frequently reported issue involves the Ocean Extra settings metabox failing to save changes on WooCommerce product pages. The problem is especially persistent when only the metabox settings are changed, without also modifying the main post body content.
Why This Happens
The issue appears to be related to how the plugin's underlying 'butterbean' framework hooks into WordPress's save_post action for certain post types. A timing conflict can prevent the metabox data from being processed correctly.
Potential Solution
Some users have reported success by modifying the plugin code to use a different WordPress hook. Specifically, changing from hooking the 'save_post' action to hooking 'pre_post_update' on line 255 of the class-butterbean.php file has resolved this issue for several community members.
Important Note: Directly modifying plugin files is not recommended as changes will be lost during updates. Consider implementing this change through a custom plugin or child theme functionality if possible.
Adding Ocean Extra Metabox to Custom Post Types
Many users want to extend Ocean Extra's functionality to their custom post types. While the plugin doesn't provide a GUI option for this, it does offer a filter hook for programmatic control.
Solution: Using the ocean_main_metaboxes_post_types Filter
You can add Ocean Extra metabox support to custom post types using this filter in your theme's functions.php file or a custom plugin:
add_filter( 'ocean_main_metaboxes_post_types', 'my_custom_metabox_settings' );
function my_custom_metabox_settings( $types ) {
// Add your custom post type
$types[] = 'my_custom_post_type';
// Return the modified array
return $types;
}
Removing Ocean Extra Metabox from Specific Post Types
Conversely, you might want to disable the metabox for certain post types where it's not needed.
Solution: Filtering Out Unwanted Post Types
This code example shows how to remove the metabox from WooCommerce products:
add_filter( 'ocean_main_metaboxes_post_types', 'remove_metabox_from_products' );
function remove_metabox_from_products( $types ) {
// Remove from products
foreach ($types as $key => $type) {
if ($type == 'product') {
unset( $types[$key] );
}
}
// Return post types array
return $types;
}
Limitations and Alternative Approaches
It's important to note that Ocean Extra's metabox functionality has some inherent limitations:
- Taxonomy Pages: The metabox cannot be added to taxonomy pages (categories, tags, etc.). For adding content to these pages, you would need to explore alternative solutions like Ocean Hooks or custom template modifications.
- User Capabilities: The metabox requires users to have the 'manage_options' capability. For sites with custom user roles, you may need to adjust capabilities through a plugin like User Role Editor.
- Post Tab Limitation: When adding metabox support to custom post types, note that the 'Post' tab (containing oEmbed URL, link, and link target options) is specifically restricted to the native 'post' post type and cannot be easily extended to custom post types through filters.
These solutions represent the collective wisdom of the OceanWP community. Always test changes on a staging site before implementing them on a live website, and consider creating backup points before modifying any code.
Related Support Threads Support
-
Metabox not saving for changes to post_type = producthttps://wordpress.org/support/topic/metabox-not-saving-for-changes-to-post_type-product/
-
Disable Ocean Extra Metabox for post typehttps://wordpress.org/support/topic/disable-ocean-extra-metabox-for-post-type/
-
Required user permissionshttps://wordpress.org/support/topic/required-user-permissions/
-
Not working with EDIT CATEGORYhttps://wordpress.org/support/topic/not-working-with-edit-category/
-
Remove comment link from recent post widgethttps://wordpress.org/support/topic/remove-comment-link-from-recent-post-widget/
-
Problem with >>recent posts widgethttps://wordpress.org/support/topic/problem-with-recent-posts-widget-3/
-
Filter to allow ‘post’ tab in ocean wp settingshttps://wordpress.org/support/topic/filter-to-allow-post-tab-in-ocean-wp-settings/
-
Custom Post Typehttps://wordpress.org/support/topic/custom-post-type-205/
-
OceanWp: Blog Filteringhttps://wordpress.org/support/topic/oceanwp-blog-filtering/
-
Enable oceanwp settings for post categorieshttps://wordpress.org/support/topic/enable-oceanwp-settings-for-post-categories/
-
Exclude Specific Category From Recent Posts Widgethttps://wordpress.org/support/topic/exclude-specific-category-from-recent-posts-widget/