• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add custom ID to div.site-inner with filter

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add custom ID to div.site-inner with filter

This topic is: not resolved

Tagged: add ids, genesis_markup_{context} filter, genesis_markup_{context}_output filter, genesis_markup(), genesis_structural_wrap-{context} filter

  • This topic has 3 replies, 2 voices, and was last updated 12 years, 3 months ago by saxisme.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • March 4, 2014 at 5:01 pm #93438
    aaronc
    Member

    Hello all,

    I'd like to add a custom ID to the <div class=".site-inner"> of my site, but am having trouble implementing the filter properly.

    I've found the genesis_markup_{context} and the genesis_markup_{context}_output filters in markup.php and attempted filtering using this code in my child theme's functions.php with no success:

    function ac_custom_site_inner( $tag, $args ) {
    	$args['html5'] = '<div id="test" %s>';
    	return $tag;
    }
    add_filter('genesis_markup_site-inner_output', 'ac_custom_site_inner' );

    Any help is greatly appreciated.

    Thanks,
    Aaron

    ----

    P.S. I've included the genesis_markup() (from markup.php) below for reference:

    /**
     * Output markup conditionally.
     *
     * Supported keys for <code>$args</code> are:
     *
     *  - <code>html5</code> (<code>sprintf()</code> pattern markup),
     *  - <code>xhtml</code> (XHTML markup),
     *  - <code>context</code> (name of context),
     *  - <code>echo</code> (default is true).
     *
     * If the child theme supports HTML5, then this function will output the <code>html5</code> value, with a call to <code>genesis_attr()</code>
     * with the same context added in. Otherwise, it will output the <code>xhtml</code> value.
     *
     * Applies a <code>genesis_markup_{context}</code> filter early to allow shortcutting the function.
     *
     * Applies a <code>genesis_markup_{context}_output</code> filter at the end.
     *
     * @since 1.9.0
     *
     * @uses genesis_html5() Check for HTML5 support.
     * @uses genesis_attr()  Contextual attributes.
     *
     * @param array $args Array of arguments.
     *
     * @return string Markup.
     */
    function genesis_markup( $args = array() ) {
    
    	$defaults = array(
    		'html5'   => '',
    		'xhtml'   => '',
    		'context' => '',
    		'echo'    => true,
    	);
    
    	$args = wp_parse_args( $args, $defaults );
    
    	//* Short circuit filter
    	$pre = apply_filters( 'genesis_markup_' . $args['context'], false, $args );
    	if ( false !== $pre )
    		return $pre;
    
    	if ( ! $args['html5'] || ! $args['xhtml'] )
    		return '';
    
    	//* If HTML5, return HTML5 tag. Maybe add attributes. Else XHTML.
    	if ( genesis_html5() ) {
    		$tag = $args['context'] ? sprintf( $args['html5'], genesis_attr( $args['context'] ) ) : $args['html5'];
    	}
    	else {
    		$tag = $args['xhtml'];
    	}
    
    	//* Contextual filter
    	$tag = $args['context'] ? apply_filters( 'genesis_markup_' . $args['context'] . '_output', $tag, $args ) : $tag;
    
    	if ( $args['echo'] )
    		echo $tag;
    	else
    		return $tag;
    }
    March 4, 2014 at 7:55 pm #93455
    aaronc
    Member

    I've also found the genesis_structural_wrap-{context} filter in layout.php on line 494.

    I tried filtering it using the following code in my child functions.php with no success:

    function ac_custom_site_inner_output( $output, $original_output ) {
    
    	switch ( $original_output ) {
    		case 'open':
    			$output = sprintf( '<div id="test" %s>', genesis_attr( 'structural-wrap' ) );
    			break;
    		case 'close':
    			$output = '</div>';
    			break;
    	}
    
    	return $output;
    }
    add_filter('genesis_structural_wrap-site-inner', 'ac_custom_site_inner_output');

    Again, any help is greatly appreciated.

    Thanks,
    Aaron

    ---

    P.S. I've included the genesis_structural_wrap() function below for convenience:

    /**
     * Potentially echo or return a structural wrap div.
     *
     * A check is made to see if the <code>$context</code> is in the <code>genesis-structural-wraps</code> theme support data. If so, then the
     * <code>$output</code> may be echoed or returned.
     *
     * @since 1.6.0
     *
     * @param string $context The location ID.
     * @param string $output  Optional. The markup to include. Can also be 'open'
     *                        (default) or 'closed' to use pre-determined markup for consistency.
     * @param boolean $echo   Optional. Whether to echo or return. Default is true (echo).
     *
     * @return string Wrap HTML.
     */
    function genesis_structural_wrap( $context = '', $output = 'open', $echo = true ) {
    
    	$wraps = get_theme_support( 'genesis-structural-wraps' );
    
    	//* If theme doesn't support structural wraps, bail.
    	if ( ! $wraps )
    		return;
    
    	//* Map of old $contexts to new $contexts
    	$map = array(
    		'nav'    => 'menu-primary',
    		'subnav' => 'menu-secondary',
    		'inner'  => 'site-inner',
    	);
    
    	//* Make the swap, if necessary
    	if ( $swap = array_search( $context, $map ) ) {
    		if ( in_array( $swap, $wraps[0] ) )
    			$wraps[0] = str_replace( $swap, $map[ $swap ], $wraps[0] );
    	}
    
    	if ( ! in_array( $context, (array) $wraps[0] ) )
    		return '';
    
    	//* Save original output param
    	$original_output = $output;
    
    	switch ( $output ) {
    		case 'open':
    			$output = sprintf( '<div %s>', genesis_attr( 'structural-wrap' ) );
    			break;
    		case 'close':
    			$output = '</div>';
    			break;
    	}
    
    	apply_filters( 'genesis_structural_wrap-' . $context, $output, $original_output );
    
    	if ( $echo )
    		echo $output;
    	else
    		return $output;
    
    }
    July 22, 2014 at 3:47 pm #115450
    saxisme
    Participant

    Hi @aaronc,

    did you managed to solve it?
    I am in the same situation.

    I've found this piece of code

    add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
    function srf_add_cust_classes() {
        add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
    } 
    function srf_add_class( $attr, $class ) {
        $attr['class'] .= ' ' . sanitize_html_class( $class );
        return $attr;
    } 
    function srf_attr_site_inner( $attr ) {
        return srf_add_class( $attr, 'example-class-1' );
    }

    here but can't make it work.

    Thanks.

    July 22, 2014 at 3:53 pm #115452
    saxisme
    Participant

    Hi @aaronc,

    I've found the solution thanks to Sridhar Katakam:

    add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
    function custom_attributes_content( $attributes ) {
     
    	if ( is_page() || is_front_page() ) { //I need it only for this type of content
    		$attributes['id'] = 'site-inner';
    	}
    	return $attributes;
    }

    Cheers!

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble