Using the filter for roots_display_sidebar

I am using roots in a mulitsite setup with several child themes. I want to have a filter for a child theme’s functions to allow the sidebar to be shown on the is_front_page on that child theme without hacking the code in the config of the parent roots theme. I know this is possible but don’t have a lot of experience creating filters. Can anyone give me the code for a filter for a child theme that would allow sidebars to be displayed on is_front_page? Your assistance is appreciated…

You can add the following to your childtheme’s lib/custom.php file:

add_filter('roots_display_sidebar', 'roots_sidebar_on_front');

function roots_sidebar_on_front($sidebar) {
  if (is_front_page()) {
    return true;
  }
  return $sidebar;
}

I needed an example for a blog post I’m writing about the sidebar, so your timing couldn’t be more fortuitous.

This is exactly what I was looking for. Just tested and it works perfectly. I think this will be helpful to a lot of people. Thanks for you assistance. Best.