OceanWP: Full-Width Layout for Selected Post Types
Makes the post types you list use OceanWP's full-width layout without a sidebar, for shops, portfolios or courses.
Opens WPIDE on
Code
// Post types that should be full width.
$wpide_ocean_full_types = array( 'product', 'portfolio' );
add_filter( 'ocean_post_layout_class', function ( $class ) use ( $wpide_ocean_full_types ) {
if ( is_singular( $wpide_ocean_full_types ) || is_post_type_archive( $wpide_ocean_full_types ) ) {
return 'full-width';
}
return $class;
} );
Notes
OceanWP layout values: full-width, full-screen, left-sidebar, right-sidebar, both-sidebars.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.