Thêm các mã sau vào tệp functions.php của bạn
// Replace WP autop formatting if ( ! function_exists( 'gd_remove_wpautop' ) ) { function gd_remove_wpautop( $content ) { $content = do_shortcode( shortcode_unautop( $content ) ); $content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content ); return $content; } // End gd_remove_wpautop() } /* ============= Two Columns ============= */ function gd_shortcode_one_half($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "one-half"; } else { $class = "one-half first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'one_half', 'gd_shortcode_one_half' ); /* ============= Three Columns ============= */ function gd_shortcode_one_third($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "one-third"; } else { $class = "one-third first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'one_third', 'gd_shortcode_one_third' ); function gd_shortcode_two_thirds($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "two-thirds"; } else { $class = "two-thirds first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'two_thirds', 'gd_shortcode_two_thirds' ); /* ============= Four Columns ============= */ function gd_shortcode_one_fourth($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "one-fourth"; } else { $class = "one-fourth first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'one_fourth', 'gd_shortcode_one_fourth' ); function gd_shortcode_two_fourths($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "two-fourths"; } else { $class = "two-fourths first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'two_fourths', 'gd_shortcode_two_fourths' ); function gd_shortcode_three_fourths($atts, $content = null) { extract(shortcode_atts( array('first' => 'no'),$atts) ); if($first == "no"){ $class = "three-fourths"; } else { $class = "three-fourths first"; } return '<div class="' . $class . '">' . gd_remove_wpautop($content) . '</div>'; } add_shortcode( 'three_fourths', 'gd_shortcode_three_fourths' );
Cách sử dụng các Mã ngắn này
1. One Half
[one_half first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ one_half]
2. Một phần ba
[one_third first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ one_third]
3. Hai phần ba
[two_thirds first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ two_thirds]
4. Một phần tư
[one_fourth first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ one_fourth]
5. Hai phần tư
[two_fourths first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ two_fourths]
6. Three
Fourths [three_fourths first = ”yes | no”] THÊM NỘI DUNG TẠI ĐÂY [/ three_fourths]