/>PHP – functions.php

function simple_table( $atts ) {
extract( shortcode_atts( array(
‘cols’ => ‘none’,
‘data’ => ‘none’,
), $atts ) );
$cols = explode(‘,’,$cols);
$data = explode(‘,’,$data);
$total = count($cols);
$output = ‘

‘;
foreach($cols as $col):
$output .= ‘

‘;
endforeach;
$output .= ‘

‘;
$counter = 1;
foreach($data as $datum):
$output .= ‘

‘;
if($counter%$total==0):
$output .= ‘

‘;
endif;
$counter++;
endforeach;
$output .= ‘

{$col}
{$datum}

‘;
return $output;
}
add_shortcode( ‘table’, ‘simple_table’ );
SHORTCODE
[table cols="names,values" data="name1,25,name2,409"]

/> /> /> Visit wpsnipp.com for details on how to setup this WordPress snippet. /> /> Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it /> />

Tags: