Skip to content

Instantly share code, notes, and snippets.

@erikkowalski
Last active February 7, 2018 18:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikkowalski/3d85a306d5d7254e2602 to your computer and use it in GitHub Desktop.
Save erikkowalski/3d85a306d5d7254e2602 to your computer and use it in GitHub Desktop.
Apply a .container or .container-fluid bootstrap class to base.php file in roots based Wordpress Theme
/**
* Return .container or .container-fluid
* Add This to lib/extras.php
*/
function container_selector( $page_url, $full_width_pages ){
if ( in_array( $page_url, $full_width_pages ) ){
return 'container-fluid';
} else {
return 'container';
}
}
/**
* Add this to base.php
* Add pages to the $full_width_pages array that you want to have a .container-fluid
* echo $container on the .wrap element
*/
<?php
$url = basename( Wrapper\template_path() );
$full_width_pages = [ 'front-page.php', 'page-about.php', ];
$container = Roots\Sage\Extras\container_selector( $url, $full_width_pages );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment