Display Sidebar on child pages using filtering?

Is there a way to use sidebar filtering to show sidebar on all pages of a certain parent.

Something like this

add_filter('roots/display_sidebar', 'roots_sidebar_on_services_page');

function roots_sidebar_on_services_page($sidebar) {
  if (is_page('services') && $post->post_parent > 0) {
    return true;
  }

  return $sidebar;
}

I tried this with no luck. Has anybody else had this issue

Seems like you would want to return $sidebar; inside your if() block and just return otherwise.

I’m guessing that services is the parent, not the child. So you will have to adapt your logic to check that the post parent id matches the services id.

You will need to check the post parent recursively if you have grandchildren involved.

You also need to declare $post as global.