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 features.php is as follows.
1 |
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 = rely($cells);$rows = ceil( $numCells / $a['cols'] );$html = '<table>';$html.= '<tbody>';for( $r = 0; $r < $rows; $r++ ){$html.= '<tr>';for( $c = 0; $c < $a['cols']; $c++ ){$index = ($r * $a['cols']) + $c;$html.= '<td>'.( ($index < $numCells) ? trim($cells[$index]) : '' ).'</td>';}$html.= '</tr>';}$html.= '</tbody>';$html.= '</table>';return $html;} add_shortcode( 'desk', '_my_theme_sc_table' ); |
Utilization is as follows:
c1, c2, c3, c4, c5, c6 |