Support » Theme: Astra » Remove sidebar on blog home

  • Hi,

    I am trying to remove the sidebar from just the blog home but not any of the archive pages. Is there an easy way to do this?

    I have a child theme and a home.php file but cannot see an easy way to target the #primary container where the width is controlled.

    Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Do you have a link to the live site where we can see this further? If you are able to provide one, might be able to provide you with some CSS that would get it removed for you.

    Thanks for the quick reply. I’m still developing the site locally unfortunately. It’s a very basic use of the theme though and I haven’t made any changes to core files.

    Alright, copy over the index.php file from the Astra parent theme into your child theme. If you are using the left sidebar option change

    <?php if ( astra_page_layout() == 'left-sidebar' ) : ?>

    into

    <?php if ( astra_page_layout() == 'left-sidebar' && ! is_home() ) : ?>

    If you are using the right sidebar option change

    <?php if ( astra_page_layout() == 'right-sidebar' ) : ?>

    into

    <?php if ( astra_page_layout() == 'right-sidebar' && ! is_home() ) : ?>

    Save the file and verify it removes the sidebar on just the homepage of the site. Assuming it worked, then you can apply the following CSS into Appearance->Customize->Additional CSS or into the child theme style.css file

    @media (min-width: 769px) {
    #primary {
    	width: auto;
    }

    OR you can use this snippet instead of overding the templates from the theme.

    
    /**
     *Set no sidebar layout on blog home page.
     */
    add_filter(
    	'astra_page_layout',
    	function ( $sidebar ) {
    		if ( is_home() ) {
    			$sidebar = 'no-sidebar';
    		}
    
    		return $sidebar;
    	}
    );
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.