Create a completely blank page

How would I create a completely blank page with no header or footer in Roots?

You can override the wrapper same as any other page:

add_filter('roots/wrap_base', 'roots_base_blank'); // Add our function to the roots_wrap_base filter

function roots_base_blank($templates) { 
  if ($yourconditions) {
    array_unshift($templates, 'base-blank.php'); // Shift the template to the front of the array
  }

  return $templates; // Return our modified array with base-blank.php at the front of the queue
}

Fantastic! Thanks for the code.

@Foxaii I added this to custom.php but to no avail. When I pull up the page using said template, it uses the original base.php, not base-blank.php. Do you see any errors in the code? Thanks in advance.

// add 'base-blank.php' template
add_filter('roots/wrap_base', 'roots_base_blank'); // Add our function to the roots_wrap_base filter

function roots_base_blank($templates) { 
  if (is_page_template('template-blank.php')) {
    array_unshift($templates, 'base-blank.php'); // Shift the template to the front of the array
  }

  return $templates; // Return our modified array with base-blank.php at the front of the queue
}

Check a few things:

  1. Is your if statement evaluating as expected?
  2. Do both template-blank.php and base-blank.php exist?
  3. Are both templates readable?
  1. It is not evaluating as expected. Even when I swapped in a simple is_page(), it did not work
  2. Yes, both templates exist in the root directory
  3. I am not sure about this question

Thanks again

The code I posted was for Roots 7 or above.

You’re using an older version so you just need to change the slash in the filter to an underscore: roots_wrap_base

1 Like

Thanks @Foxaii. This worked for my installation of Roots Version: 6.5.2.

Has this function changed since Sage? The following should work but can’t seem to get it to load the new base

add_filter('roots/wrap_base', 'roots_base_minimal');
function roots_base_minimal($templates) {
    // conditional check if anything matches
    if (is_page( array(91, 14790, 14788, 'custom-page')) ) {
       array_unshift($templates, 'base-minimal.php'); // Shift the template to the front of the array
    }
    return $templates; // Return our modified array with base-minimal.php at front of queue
}

nv got it working :stuck_out_tongue:

add_filter('sage/wrap_base', __NAMESPACE__ . '\\sage_wrap_base_minimal');

i was wondering if this could be used in a plugin?