Keep sidebar on homepage, delete on blog posts?

How do I go about keeping sidebar on homepage but removing it from blog posts?

Thank you!

Hello Theodore,

Thanks for writing in!

You can make the changes from X > Theme Options > Layout and Designs > Content Layout and select Full Width.

Thanks.

Thanks for the reply! However, this doesn’t resolve the issue. The sidebar still appears, any other suggestions that might prevent this from adjusting?

I’ll send secure note to you

Thank you!

Hello Theodore,

By default, the homepage or your blog index page should follow the global layout settings in X > Theme Options > Layout & Design > Content Layout. Both the blog index and the single posts is using this settings. If you want to force that only the homepage or blog index will use the sidebar and fullwidth for single posts, please add the following code in your child theme’s functions.php file

// Make sure that only the blog index has the sidebar
// and no sidebar on single posts
// =============================================================================
function no_sidebars_on_post($contents) {
  if ( is_home() ) {
    $contents = 'content-sidebar';
  } else {
    $contents = 'fullwidth';
  }
  
  return $contents;
}
add_filter('x_option_x_layout_content', 'no_sidebars_on_post', 5);
// =============================================================================

We would love to know if this has worked for you. Thank you.

Added this to child theme functions.php and it messed things up lol. the blue shows up on the left hand side

Hello Theodore,

In the code, content-sidebar means that the content is on the left and sidebar on the right.
sidebar-content will display the blue sidebar on the left and the content on the right.

Could you please apply the code so we can check it? Maybe if you can provide us access to the site would be better so that we can investigate further and check your layout settings as well.

Thank you in advance.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.