Error when filtering the sidebar display in extras.php

I’m trying to filter my sidebar display so that the sidebar only appears on pages using a custom template - template-sidebar.php

I’ve tried adding the following code to extras.php as outlined in the Sage docs at https://roots.io/sage/docs/theme-sidebar/

[code]add_filter(‘sage/display_sidebar’, NAMESPACE . ‘sage_sidebar_on_special_page’);

function sage_sidebar_on_special_page($sidebar) {
if (is_page_template(‘template-sidebar.php’)) {
return true;
}
return $sidebar;
}[/code]

Unfortunately I’m getting the following error as a result:

( ! ) Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'Roots\Sage\Extrassage_sidebar_on_special_page' not found or invalid function name in /Users/peterrees/Dropbox/Dev/www.htw.dev/wp-includes/plugin.php on line 235

PHP noob here so any help would be appreciated!

The code example on that page was wrong, just fixed it. See https://github.com/roots/docs/commit/2b93e9d90bf84f8488ca4406cd325e77d1063397

1 Like

That did the trick. Thanks, Ben!