1
votes

Hello I am trying to convert my grid.css file into wordpress shortcodes however I am having an issue.

What I want to see:

<div class="row>
    <div class="columns one">Content</div>
    <div class="columns three">Content</div>
</div>

What I get:

[column_one]Awesome[/column_one] [column_three]Stuff[/column_three]

My Code:

<?php while ( have_posts() ) : the_post();
$content = get_the_content();
echo do_shortcode($content);
endwhile; // end of the loop. ?>

I am trying this on a simple page template.

How can I get it to function properly?

Thank you.

1

1 Answers

1
votes

You shouldn't need to add do_shortcode in your loop. Better would be adding it in the functions.php file like so:

function column_one( $atts, $content = null ) {
    return '<div class="columns one">'.do_shortcode($content).'</div>';
}

add_shortcode('column_one', 'column_one');