This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Reply To: 70/30 Column Width Using Shortcode

#3103
Jason Bobich
Keymaster

Hello Angela,

In terms of adding these to the framework, I kind of think this might be getting a little overboard on the column shortcodes, but there are CSS classes that you could utilize if you wanted to create these shortcodes in your Child theme.

Here’s how you’d do it:

/**
 * My custom column shortcodes
 */

function my_shortcode_columns( $atts, $content = '', $tag = '' ) {
	
	// Determine if column is last in row
	$last = '';
	if ( isset( $atts[0] ) && trim( $atts[0] ) == 'last')
		$last = ' last';

	// Figure out grid class to use
	$class = 'column ';
	switch( $tag ) {
		case 'seven_tenth' :
			$class .= 'grid_tenth_7';
			break;
		case 'three_tenth' :
			$class .= 'grid_tenth_3';
			break;
	}

	// Return column
	$content = '<div class="'.$class.$last.'">'.$content.'</div>';
	return do_shortcode( $content );

}
add_shortcode( 'seven_tenth', 'my_shortcode_columns' );
add_shortcode( 'three_tenth', 'my_shortcode_columns' );

Let me know if that doesn’t work; I didn’t test it.

[seven_tenth]Column 1...[/seven_tenth]
[three_tenth last]Column 2...[/three_tenth]
[clear]