Site logo

Archived topic

Search sidebar

3 replies · Started by Robert on November 7, 2017

Viewing posts 1–4 of 4

Hello,

I'm having an issue with a sidebar that shows up when a search is performed that contains an archive widget and a search widget, as seen here: https://cl.ly/0J0u2g1N3M0O.

The issue is that I don't have any default sidebar that has the archives widget in it so wondering where this is coming from and how I can get rid of it. Thanks.

Hi there,

You can use this filter to remove the sidebars on the search page: https://docs.generatepress.com/article/generate_sidebar_layout/

For example:

add_filter( 'generate_sidebar_layout', 'tu_no_sidebar_search' );
function tu_no_sidebar_search( $sidebar ) {
    if ( is_search() ) {
        return 'no-sidebar';
    }

    return $sidebar;
}

By default, the search results will use the sidebar layout you have set in Customize > Layout > Sidebars > Blog Sidebar

Thanks Tom!

You're welcome :)

This archived topic is closed to new replies.