Full width for non page templates

I have a few custom php files that need to be full width. In earlier version we used…

function roots_display_sidebar() {
  $sidebar_config = new Roots_Sidebar(
    array(
      'is_404',
      'is_front_page',

      array( 'in_array', 
        array( 
          basename( roots_template_path() ), 
          array( 
            'property.php',
            'propertysearch.php',
            'listing.php',
            'la-wizard.php', 
            'archive-bar.php' // your template files here...
          ) 
        ) 
      )

    ),
    array(
      'template-custom.php'
    )
  );
  
  return $sidebar_config->display;
}

but this is not working currently. I am not quite sure how to add these php files using Roots_Sidebar.

The support for that workaround was dropped to better support the WordPress conditional tags. You can use something like the following instead:

function is_wrapper_template($templates) {
  $main_template = basename(roots_template_path());

  if (is_array($templates)) {
    return in_array($main_template, $templates);
  } else {
    return $main_template === $templates;
  }
}

You would then call:

function roots_display_sidebar() {
  $sidebar_config = new Roots_Sidebar(
    array(
      'is_404',
      'is_front_page',
      array('is_wrapper_template', 
        array( 
          'property.php',
          'propertysearch.php',
          'listing.php',
          'la-wizard.php', 
          'archive-bar.php' // your template files here...
        )
      )
    ),
    array(
      'template-custom.php'
    )
  );

  return $sidebar_config->display;
}
2 Likes

Works great! Thank you very much.