# GeneratePress: No Sidebar on Selected Post Types

> Removes the sidebar in GeneratePress for the post types and archives you list, for full-width shop, course or portfolio pages.

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

## Code

```php
// Post types that should be full width.
$wpide_gp_full_types = array( 'product', 'page' );

add_filter( 'generate_sidebar_layout', function ( $layout ) use ( $wpide_gp_full_types ) {
    if ( is_singular( $wpide_gp_full_types ) || is_post_type_archive( $wpide_gp_full_types ) ) {
        return 'no-sidebar';
    }

    return $layout;
} );
```

## Notes

Layout values GeneratePress accepts: no-sidebar, right-sidebar, left-sidebar, both-sidebars.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "GeneratePress: 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/
