Full-Width Blog Posts in Divi
Removes the sidebar from single blog posts in the Divi theme and gives the content the full width, without editing each post's layout setting.
Opens WPIDE on
Code
// Post types that should always be full width.
$wpide_divi_full_width_types = array( 'post' );
add_filter( 'get_post_metadata', function ( $value, $object_id, $meta_key ) use ( $wpide_divi_full_width_types ) {
if ( '_et_pb_page_layout' !== $meta_key || is_admin() ) {
return $value;
}
if ( in_array( get_post_type( $object_id ), $wpide_divi_full_width_types, true ) ) {
return array( 'et_full_width_page' );
}
return $value;
}, 10, 3 );
Notes
Change post to another post type slug, or add more, in $wpide_divi_full_width_types.
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.