• Skip to primary navigation
  • Skip to main content
  • Skip to footer

JH Tech Services

A knowledgebase

  • Portfolio
  • Knowledgebase
  • About

Replacing Genesis wrap with Bootstrap wrap on WordPress

February 20, 2019 by jer0dh

When creating a theme and using Bootstrap, this code is a beginning in letting us change out the default wrap of Genesis with Bootstrap’s.


add_action( 'init', 'gwto_init_structural_wrap');

/**
 * Defines where structural wraps will occur in theme and adds filter to each to change markup to bootstrap wrap
 *
 *
 */
function gwto_init_structural_wrap() {

    $structural_wraps = array(
        'header',
        'menu-primary',
        'menu-secondary',
        'footer-widgets',
        'footer'
    );

    add_theme_support( 'genesis-structural-wraps', $structural_wraps );

    foreach( $structural_wraps as $wrap ) {
        add_filter(  "genesis_structural_wrap-{$wrap}", 'gwto_structural_wrap', 15, 2 );
    }
}

/**
 * Adds opening or closing bootstrap wrap depending on $original_output
 *
 * @param $output
 * @param $original_output
 *
 * @return string
 */
function gwto_structural_wrap( $output, $original_output ) {

    switch ( $original_output ) {
        case 'open':
            $output = '
'; break; case 'close': $output = '
'; break; } return $output; }
  • Knowledgebase

Footer

  • Portfolio
  • Knowledgebase
  • About

© 2023