I am using twitter boostrap in my recent project . I want that the post or page content will split into columns. For doing this I am declaring several shortcode like this

function two_column($atts,$content=NULL){
    return ('<div class="col-md-6">'. $content .'</div>');
add_shortcode('two_column', 'two_column');

function three_column($atts,$content=NULL){
    return ('<div class="col-md-4">'. $content .'</div>');
add_shortcode('column', 'three_column');
function four_column($atts,$content=NULL){

    return ('<div class="col-md-3">'. $content .'</div>');
add_shortcode('four_column', 'four_column');

Now if I need to split content in , then I just need to this

[two_column]content in first column[/two_column]
[two_column]content in second column[/two_column]

and so on for three or four column

But I want to make a short code like this

[column count=2]Content [/column] , I will just change the value of count , and then content will automatically split .


First of all: Please read this: http://codex.wordpress.org/Shortcode_API Everything you need to know about shortcode parameters is in there.

Second: If you want to split content automatically into two or more columns, why don't you use css? http://www.w3schools.com/css/css3_multiple_columns.asp works pretty good.

Happy Coding, Kuchenundkakao

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.