Support » Plugins » Hacks » Add shortcode Columns in a div wrapper

  • I’ve been trying to find a solid working solution online on how I can return shortcode columns in an outer wrapper container such as a div. Does anyone have a method that works?

    My test code for returning the column, in this case, a one_third column:

    if ( !function_exists('my_column') ) {
    	function my_column( $atts, $content = null ) {
    			'column' => 'one-third',
    			'last' => false,
    		), $atts));
    		$last_class = '';
    		$last_div = '';
    		if( $last ) {
    			$last_class = 'myclass-column-last';
    			$last_div = '<div class="clearfix separator"></div>';
    		return '<div class="myclass-' . $column . $last_class . '">' . do_shortcode($content) . '</div>' . $last_div;
    	add_shortcode('my_column', 'my_column');

    The shortcode columns is generated from the editor and you would click the Add Column button to get your columns created before you click Insert (into your page). The problem is, I need my multiple columns to be wrapped in a <div> but do not know how this is done. I’ve looked online but the closest tutorial I came across was from 4 years ago and didn’t work. Currently at the moment, I created a “column wrapper” shortcode which you would then add the columns into that via the shortcode generator, but to me that doesn’t sound efficient.

    Thanks in advance 🙂

  • The topic ‘Add shortcode Columns in a div wrapper’ is closed to new replies.