logo logo
  • Tài liệu
      • Công cụ
      • Email Yandex
      • Kinh Nghiệm
      • Mã nguồn
        • Blogspot
          • Chuyên gia Blogspot
        • WHMCS
        • WooCommerce
        • WordPress
          • Advanced custom fields
          • Elementor
          • Zubi Cloud Builder
        • Xenforo
      • Phần mềm
      • Plugin
      • Quản trị Server
        • CWP – CentOS Web Panel
        • CyberPanel
        • Digital ocean
        • HocVPS Script
        • Vultr
      • SEO
      • Support Admin
      • Tài liệu
        • Zubi Cloud Store
      • Tên miền
  • Tài nguyên
    • Công cụ
    • Phần mềm
    • Share template
  • Support
    • Liên hệ
    • Support 24/7
  • Đăng nhập
  • Đăng ký
  • Bí kít nghề
Services

Tài liệu hỗ trợ khách hàng Zubi Cloud

"Lời hứa từ Thabidu Group, dịch vụ và sản phẩm của chúng tôi là trọn đời, trường cửu."

  • Trang chủ
  • WordPress
  • Cách tạo Menu kéo thả trong WordPress
14/01/2020 - 149 views

Cách tạo Menu kéo thả trong WordPress

Zubi Cloud chia sẻ thủ thuật tạo Menu dạng kéo thả trong wordpress, dành cho chuyên gia thiết kế theme wordpress

1.Cách tạo Menu dạng kéo thả trong wordpress

Chèn đoạn code sau vào file functions.php

add_theme_support( 'menus' ); register_nav_menus( array( 'main-nav' => 'Zubi Cloud Menu top' ) );

Chèn đoạn code sau vào nơi cần hiển thị Menu

<?php wp_nav_menu( array(
'theme_location' => 'main-nav', // tên location cần hiển thị
'container' => 'ul', // thẻ container của menu
) ); ?>

2. Xem tiếp bài Tạo Section tùy biến kéo thả HTML trong WordPress

Chèn đoạn code sau vào file functions.php

require_once get_template_directory() . '/customizer-anbiwebfooter.php';
require_once get_template_directory() . '/customizer-anbiwebhead.php';

Tiếp theo hãy tạo 2 file customizer-anbiwebfooter.php và customizer-anbiwebhead.php ngang hàng với file functions.php trong theme (hoặc có thể đặt 2 file trên vào 1 folder nào đó, tùy ý bạn muốn)

Chèn đoạn code sau vào customizer-anbiwebhead.php

<?php
function head_customize_register($wp_customize) 
{
$wp_customize->add_section("head1", array(
'title' => __("Thay đổi logo, hotline"),
'priority' => 130,
));


//Code upload ảnh
$wp_customize->add_setting("footer_logo", array(
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize,'footer_logo',array(
'label' => __('Upload ảnh', 'devvn'),
'section' => 'head1',
'settings' => 'footer_logo',
))); 


//Code chèn text
$wp_customize->add_setting("head_text", array(
'default' => '',
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Control($wp_customize,"head_text",array(
'label' => __("Thay đổi hotline"),
'section' => 'head1',
'settings' => 'head_text',
'type' => 'textarea',
)));


}
add_action("customize_register","head_customize_register");

Chèn đoạn code sau vào customizer-anbiwebfooter.php

<?php

function footer_customize_register($wp_customize) 
{
$wp_customize->add_section("footer1", array(
'title' => __("Tùy biến Zubi Cloud Footer"),
'priority' => 130,
));

//Footer text
$wp_customize->add_setting("footer_text", array(
'default' => '',
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Control($wp_customize,"footer_text",array(
'label' => __("Bản đồ"),
'section' => 'footer1',
'settings' => 'footer_text',
'type' => 'textarea',
)));


//Footer text
$wp_customize->add_setting("footer_text1", array(
'default' => '',
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Control($wp_customize,"footer_text1",array(
'label' => __("Like facebook"),
'section' => 'footer1',
'settings' => 'footer_text1',
'type' => 'textarea',
))); 


//Footer text
$wp_customize->add_setting("footer_text2", array(
'default' => '',
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Control($wp_customize,"footer_text2",array(
'label' => __("Thông tin công ty"),
'section' => 'footer1',
'settings' => 'footer_text2',
'type' => 'textarea',
))); 


//Footer text
$wp_customize->add_setting("footer_text3", array(
'default' => '',
'transport' => 'postMessage',
)); 
$wp_customize->add_control(new WP_Customize_Control($wp_customize,"footer_text3",array(
'label' => __("Thanh Hotline"),
'section' => 'footer1',
'settings' => 'footer_text3',
'type' => 'textarea',
))); 



}
add_action("customize_register","footer_customize_register");

Cách gọi cách hàm trên, chèn đoạn code sau vào nơi cần hiển thị trong themes:

<?php echo get_theme_mod( 'head_text' ); ?>

hay

<?php echo get_theme_mod( 'footer_logo' ); ?>

Tags: carrental_customize, carrental_logo, Customize, head_customize, register_nav_menus, Thay đổi logo, WordPress, wordpress menu

Bài liên quan
  • Cách xóa bỏ chữ Bảo vệ, Private, Protected trước tiêu đề bài viết WordPress
  • Cách thêm code HTML trong Author bio WordPress
  • Cách cài SMTP gmail không cần dùng Plugin SMTP
  • Cách tạo Popup Form trong WordPress chuyên nghiệp nhất
  • Danh sách các Shortcodes trong LearnPress
  • Công cụ (6)
  • Kinh Nghiệm (1)
  • Mã nguồn (99)
    • Blogspot (20)
      • Chuyên gia Blogspot (1)
    • WHMCS (4)
    • WooCommerce (15)
    • WordPress (64)
      • Advanced custom fields (2)
      • Elementor (1)
      • Zubi Cloud Builder (1)
    • Xenforo (2)
  • Phần mềm (2)
  • Plugin (1)
  • Quản trị Server (33)
    • CWP – CentOS Web Panel (5)
    • CyberPanel (10)
    • Digital ocean (1)
    • HocVPS Script (11)
    • Vultr (1)
  • SEO (2)
  • Support Admin (9)
  • Tài liệu (1)
    • Zubi Cloud Store (1)
  • Tên miền (1)
Bài xem nhiều
    • Thay chữ Sale giảm giá bằng % trong woocommerce WordPress

      post 11/08/2019 - 647 views
    • Cách sửa giao diện trang quản lý user trong CWP Control

      post 11/08/2019 - 535 views
    • 1 số cách viết đường dẫn khi thiết kế Theme WordPress

      post 11/08/2019 - 471 views
    • Code lấy ảnh đầu tiên trong bài viết làm ảnh đại diện Auto Post Thumbnail

      post 11/08/2019 - 447 views
    • Công cụ Tool mã hóa code Blogspot chuẩn

      post 05/09/2019 - 398 views

    Các kênh hỗ trợ

    Chúng tôi luôn ở đây 24/7 hỗ trợ bạn, đi cùng bạn trên chặng đường kinh doanh và phát triển doanh nghiệp

  • Gửi yêu cầu

  • Chát trực tuyến 24/7

  • zubicloud@gmail.com

  • Cài đặt Ultraviewer/Teamviewer

1 sản phẩm của Thabidu
  • Liên hệ
  • Support 24/7
  • Theme Store
  • App Store