TODO: To change the footer's content go to Dr.Explain menu Options : Project Settings : HTML (CHM) Export : Setup HTML Template and Layout
Tiêu đề widget
- Cho phép hiển thị HTML cho tiêu đề widget:
remove_filter( 'widget_title', 'esc_html' );
- Sửa tiêu đề widget bạn có thể chỉ định vào widget bởi tham số $id_base được truyền vào hàm filter widget_title. VÍ dụ sau tôi lấy tiêu đề của trang bài viết hiện tại làm tiêu đề widget.
function myplugin_widget_title( $title, $instance, $id_base ) {
if ( !is_single() ) {
return $title;
}
$post_title = get_the_title();
switch ( $id_base ) {
case 'pages': return sprintf( '%s "%s"', $title, $post_title );
case 'links': return sprintf( 'Links for "%s" post.', $post_title );
Ý tưởng là tạo biến toàn cục lưu trữ các liên kết của widgets, tiếp đó sử dụng hook 'widget_title' chúng ta sẽ thiết lập liên kết dựa vào tiêu đề có lưu ở biến toàn cục đó.
add_action('init','setup');
function setup(){
global $w_title_links;
$w_title_links=array(
'danh-sach-san-pham'=>site_url('san-pham'), //for home widget
'ban-chay-nhat'=>site_url('ban-chay'), //for home widget
'ban-chay-nhayt'=>site_url('ban-chay'), //for home widget
'ban-chay'=>site_url('ban-chay'), //for home widget
'giam-gia'=>site_url('giam-gia'),
'gio-hang'=>site_url('gio-hang'),
'gia-hang'=>site_url('gio-hang')
);
}
Sửa tiêu đề widget với filter 'widget_title'.
/*
* note: we cover widget title on hook 'dynamic_sidebar_params' but this hook may be work with together, because 'dynamic_sidebar_params' can't change widget title
*/
add_filter('widget_title','widget_title_link');
function widget_title_link($title){
global $w_title_links;
$not_in = array('danh-sach-san-pham','ban-chay-nhat','ban-chay-nhayt'); #don't apply for those