Bài viết “Một số thủ thuật cho Genesis framework” dưới đây hy vọng sẽ giúp ích được nhiều cho các bạn trong việc tùy chỉnh theme của mình, đặc biệt là child theme của genesis
Các bạn sẽ sử dụng các đoạn code chèn vào file functions.php trong child theme:
Tùy chỉnh khung search
Đổi text trong khung seach
add_filter( 'genesis_search_text', 'custom_search_text' );
function custom_search_text($text)
return esc_attr( 'Nội dung text' );
Đổi text ở button
add_filter('genesis_search_button_text', 'be_custom_search_button_text');
function be_custom_search_button_text( $text )
return esc_attr( 'Tìm' );
Hiện author box ở cuối bài viết
Hiện author box
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
Thay đổi kích thước avatar
function change_default_comment_text($args)
$args['title_reply'] = 'Leave a Comment';
return $args;
add_filter( 'genesis_comment_form_args', 'change_default_comment_text' );
Trong đó 80 là kích thước avatar, bạn có thể sửa lại thông số này theo ý của bạn.
Đổi “Speak your mind” ở comment
function change_default_comment_text($args)
$args['title_reply']='Gửi bình luận';
return $args;
add_filter( 'genesis_comment_form_args', 'change_default_comment_text' );
Bỏ hoặc đổi Post info của bài viết
Bỏ post info
remove_action('genesis_before_post_content', 'genesis_post_info');
Đổi post info
add_filter('genesis_post_info', 'be_post_info_filter');
function be_post_info_filter($post_info)
$post_info = 'Đăng bởi [ post_author_posts_link ] lúc [ post_time ]
ngày [ post_date ] [ post_comments ] [ post_edit ]';
return $post_info;
Bạn nhớ bỏ khoảng trắng bên trong dấu [ ].
Bỏ hoặc đổi Post meta của bài viết
Bỏ post meta
remove_action('genesis_after_post_content', 'genesis_post_meta');
Đổi post meta
add_filter('genesis_post_meta', 'be_post_meta_filter');
function be_post_meta_filter($post_meta)
$post_meta = '[ post_categories sep="/" before="Chuyên mục: "] [ post_tags sep="/" before="Thẻ: " ]';
return $post_meta;
Đổi “Read more” trong Genesis
function be_more_link($more_link)
return sprintf('<p><a href="%s" class="more-link">%s</a></span></p>',
get_permalink(), 'Xem chi tiết');
add_filter( 'excerpt_more', 'be_more_link' );
add_filter( 'get_the_content_more_link', 'be_more_link' );
add_filter( 'the_content_more_link', 'be_more_link' );
Ẩn tiêu đề trang
add_action('get_header', 'child_remove_page_titles');
function child_remove_page_titles()
if (is_page())
remove_action('genesis_post_title', 'genesis_do_post_title');
Đổi favicon cho Genesis
add_filter('genesis_favicon_url', 'custom_favicon_url');
function custom_favicon_url()
$favicon = "http://domain.com/favicon.ico";
return $favicon;
Tùy biến cho breadcrumb
add_filter( 'genesis_breadcrumb_args', 'raynoblog_breadcrumb_args' );
function raynoblog_breadcrumb_args( $args )
$args['home'] = 'Trang chủ ';
$args['sep'] = ' / ';
$args['list_sep'] = ', ';
$args['prefix'] = '<div class="breadcrumb"><div class="wrap">';
$args['suffix'] = '</div></div>';
$args['labels']['prefix'] = '<span class="home"></span>';
return $args;
Trên đây là một số thủ thuật nhỏ dành cho Genesis các bạn có thể tham khảo và sử dụng. Chúc các bạn thành công!
Một số thủ thuật cho Genesis framework
0 nhận xét:
Đăng nhận xét
Click to see the code!
To insert emoticon you must added at least one space before the code.