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

[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;

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/ on line 235

PHP noob here so any help would be appreciated!

The code example on that page was wrong, just fixed it. See

1 Like

That did the trick. Thanks, Ben!