Astra: No Sidebar on Selected Post Types
Removes the sidebar in the Astra theme for the post types you list, such as products, courses or landing pages, without changing each item's settings.
Opens WPIDE on
Code
// Post types that should never show a sidebar.
$wpide_astra_full_types = array( 'page', 'product' );
add_filter( 'astra_page_layout', function ( $layout ) use ( $wpide_astra_full_types ) {
if ( ! defined( 'ASTRA_THEME_VERSION' ) ) {
return $layout;
}
if ( is_singular( $wpide_astra_full_types ) || is_post_type_archive( $wpide_astra_full_types ) ) {
return 'no-sidebar';
}
return $layout;
} );
Notes
Only runs while Astra is the active theme. Per-post sidebar settings set in the editor are overridden for these 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.