Activate sidebar on custom template

I’m using Sage 9 beta 3 and created a custom taxonomy. For that I also created a new template located:
/wp-content/themes/<theme-name>/resources/views/taxonomy-<taxonomy-name>.blade.php
How can I “activate” the sidebar for this new template? I use the default app.blade.php layout which has already OOTB the sidebar condition:

@if (App\display_sidebar())
...
@endif

in place.

But on the mentioned template I don’t get the sidebar printed out.

1 Like

I am having the exact same issue. Have you figured it out?

I just found a reference to this implementation by searching Github issues: https://github.com/roots/docs/blob/sage-9/sage/theme-sidebar.md#displaying-the-sidebar

Looks like they deliberately removed the example filter from the boilerplate and expect theme devs to use it as needed: https://github.com/roots/sage/pull/1883

Ok. Adding the following code into /app/filters.php

add_filter('sage/display_sidebar', function ($display) {
    static $display;

    isset($display) || $display = in_array(true, [
      // The sidebar will be displayed if any of the following return true
      is_tax(),
      // ... more types
    ]);

    return $display;
});

works for me. The filter is already included here: https://github.com/roots/sage/blob/9.0.0-beta.3/app/helpers.php#L87

3 Likes