table 1 - Create a table in WordPress without plugin or code

Create a table in WordPress without plugin or code

Posted on

Create a desk in WordPress with out plugin or code

You possibly can obtain this utilizing Shortcodes within WordPress. Including them is comparatively easy. A fundamental working instance of making this shortcode within your theme capabilities.php is as follows.

operate _my_theme_sc_table( $atts, $content material ){// Normalise the attributes:$a = shortcode_atts(array('cols' => 4), $atts);// Now extract the content material (will probably be a CSV of things):$cells = explode(',', $content material);$numCells = depend($cells);$rows  = ceil( $numCells / $a['cols'] );$html = '
';$html.= '';for( $r = 0; $r < $rows; $r++ ){$html.= '';for( $c = 0; $c < $a['cols']; $c++ ){$index = ($r * $a['cols']) + $c;$html.= '';}$html.= '';}$html.= '';$html.= '
'.( ($index < $numCells) ? trim($cells[$index]) : '' ).'
';return $html;} add_shortcode( 'desk', '_my_theme_sc_table' );

Utilization is as follows:

table - Create a table in WordPress without plugin or code
Output

c1, c2, c3, c4, c5, c6