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:
- Hiển thị tất cả comment trong web wordpress, các tham biến của hàm WP_Comment_Query wordpress,
- Table responsive cho các thiết bị mobile table, thay thế table cho flatsome
- Tạo 1 title UX Builder đơn giản, hiển thị danh mục sản phẩm woocommerce
- MỘT SỐ MÃ MÀU GRADIENT ĐẸP
- 10 phím tắt cực kỳ hữu ích cho người dùng Window