Black Friday sale! Get up to 25% off GP Premium! Learn more ➝

[Resolved] Remove text widget or whole sidebar from Search Results

Home Forums Support [Resolved] Remove text widget or whole sidebar from Search Results

Home Forums Support Remove text widget or whole sidebar from Search Results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #121995
    Michael

    Hi all,

    First – thanks Tom for a great theme. I’m completely new to all of this and your theme has made it very easy to get up an running.

    I’ve signed up for an Adsense account and have the ads showing up on some of my pages using a combination of a text widget in the left sidebar on some pages and a hook on others.

    What I want to do is disable the sidebar entirely from the search page or remove the text widget I added to the left sidebar so the Adsense ad does not appear on the search results page.

    I have customcss which I am using the following code in, if that makes a difference:

    body.page-id-4 .grid-container {
    max-width: 98%;
    }

    I can’t just tell the page to run another sidebar because those are setup for other pages. Is there a way to do this on the search page?

    Thank you!

    #122001
    bdbrown

    Hi Michael. Take a look at this KB article.

    #122002
    Michael

    Thank you, bdbrown!

    I used what I read there and after doing some searches found that I should change the category to search. My Custom CSS now has this in it, but the sidebar still shows on the search page. Do I have to do something special when adding more than one thing to the Custom CSS?

    Thank you!

    body.page-id-4 .grid-container {
          max-width: 98%;
    }
    add_filter( 'generate_sidebar_layout','generate_custom_category_sidebar_layout' );
    function generate_custom_category_sidebar_layout( $layout )
    {
     	// If we are on a category, set the sidebar
     	if ( is_search() )
     	 	return 'no-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }
    #122003
    bdbrown

    The function would go in a child theme functions.php file, not your css file. More information here.

    You can download a blank child theme for GP here: http://generatepress.com/api/themes/generatepress_child.zip

    #122005
    Michael

    It worked! I used a plugin to adjust the function and now the search results page has no sidebar. Won’t have to worry about AdSense saying I have ads on a search page now!

    Thanks a lot, bdbrown!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.