Thêm tùy biến giao diện wordpress
Đăng ngày: 11-08-2023
58 lượt xem
Sau đây kho web đẹp sẽ hướng dẫn các bạn từng bước tùy biến giao diện theo nhu cầu riêng
B1. Vào file functions.php ==> Đăng ký hàm tùy biến, sau đó viết nội dung code vào trong hàm
function PTL_customize_register($wp_customize){
}
add_action(‘customize_register’,’PTL_customize_register’);
B2: Đăng ký section
$wp_customize->add_section(“social“, array(
‘title’ => ‘Tùy biến mạng xã hội’,
‘priority’ => 130,
‘description’ => __(‘Tùy biến mạng xã hội tại đây’),
));
B3: Đăng ký các control thuộc section vừa tạo
$wp_customize->add_setting(“social_facebook“, array(
‘default’ => ”,
‘transport’ => ‘postMessage’
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize,”social_facebook“,
array(
‘label’ => ‘Fanpage Facebook’,
‘section’ => ‘social‘,
‘settings’ => ‘social_facebook’,
‘type’ => ‘textarea’
)
));
Xem code đầy đủ function PTL_customize_register($wp_customize){ $wp_customize->add_section("social", array( 'title' => 'Tùy biến mạng xã hội', 'priority' => 130, 'description' => __('Tùy biến mạng xã hội tại đây'), )); $wp_customize->add_setting("social_facebook", array( 'default' => '', 'transport' => 'postMessage' )); $wp_customize->add_control(new WP_Customize_Control($wp_customize,"social_facebook", array( 'label' => 'Fanpage Facebook', 'section' => 'social', 'settings' => 'social_facebook', 'type' => 'textarea' ) )); } add_action('customize_register','PTL_customize_register');