Tạo widget đè lại widget cũ trong child theme trên flatsome

Đây là code mẫu:
function my_flatsome_widgets_init() {
remove_action( ‘widgets_init’, ‘flatsome_widgets_init’ );

$title_before = ”;
$title_class  = ”;
$title_after  = ‘

‘;

register_sidebar( array(
‘name’          => __( ‘Footer 2’, ‘flatsome’ ),
‘id’            => ‘sidebar-footer-2’,
‘before_widget’ => ‘

‘,
‘after_widget’  => ‘

‘,
‘before_title’  => ‘

‘,
‘after_title’   => ‘

‘,
) );
}

add_action( ‘widgets_init’, ‘my_flatsome_widgets_init’, 0);

Đầu tiên, cần remove action cũ của main theme.  Sau đó thêm action cho child theme, lưu ý thứ tự số ở cuối cùng (ở đây là số 0 )

Link tham khảo:
https://wordpress.stackexchange.com/questions/203618/widgets-init-actions-not-fired-from-functions-phps-child-theme

Leave a Reply

Your email address will not be published. Required fields are marked *