# 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.

- Type: PHP
- Runs: Frontend only
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: astra, sidebar, layout
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/astra-no-sidebar-for-post-types/

## Code

```php
// 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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Astra: No Sidebar on Selected Post Types" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
