Menu thông thường chỉ được xài cho Header và Footed tuy nhiên nếu bạn muốn phá cách mang menu đi khắp mọi nơi thì hãy biến em nó thành Shortcode rồi xài nhé! Đoạn code biến menu thành shortcode chỉ bao gồm vài dòng như bên dưới
1 2 3 4 5 6 |
//Codfe.com Tạo shortcode menu [menu name="menu_name"] function print_menu_shortcode($atts, $content = null) { extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts)); return wp_nav_menu( array( 'menu' => $name, 'menu_class' => 'myclass', 'echo' => false ) ); } add_shortcode('menu', 'print_menu_shortcode'); |
Css cho menu dọc thành ngang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#header { background-color:#565656; color:white; text-align:center; height:10%; } #header ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; text-align:center; } #header li { display:inline; } #header li a { display: inline-block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; vertical-align: middle; } #header li a:hover { background-color: #111; } |
Bài viết mới:
- Tạo nút Read More / Read Less (Xem thêm / Ẩn nội dung) cho nội dung quá dài trong wordpress
- Hiển thị mã sản phẩm (SKU) trong trang sản phẩm
- Ẩn nút Thanh toán – check out trong qua trình thanh toán Woocommerce
- Lỗi bảo mật nghiệm trọng của plugin wpDiscuz
- 5 phần mềm khôi phục dữ liệu trả phí tốt nhất cho Windows