---
title: "Tổng hợp code tùy biến khung bình luận trong Genesis"
author: "Trung Hiếu"
date: "2014-12-29"
lastmod: "2022-06-19"
url: "https://wpcanban.com/wordpress/thu-thuat-wordpress/tong-hop-code-tuy-bien-khung-binh-luan-trong-genesis.html"
---

# Tổng hợp code tùy biến khung bình luận trong Genesis

Tổng hợp code tùy biến khung bình luận trong Genesis Framework và Genesis child theme.

![tong-hop-code-tuy-bien-khung-binh-luan-trong-genesis](https://wpcanban.com/wp-content/uploads/2014/12/genesis-comments-code-snippets.png)

Bạn mới bắt đầu làm quen với Genesis Framework? Bạn đang tìm cách để tùy biến khung bình luận của [Genesis Framework](https://wpcanban.com/tag/genesis-framework) hay Genesis child theme theo ý của mình nhưng chưa biết làm thế nào? Hôm nay, tôi sẽ giới thiệu đến các bạn các code snippet hữu ích giúp tùy biến khung bình luận của [Genesis](https://wpcanban.com/tag/thu-thuat-genesis/) một cách đơn giản và hiệu quả mà không cần biết nhiều về PHP code. Những code này được tổng hợp và Việt hóa từ nhiều nguồn khác nhau trên internet.

Tham khảo thêm:

- [Tùy biến nút submit trong khung comment của Genesis](https://wpcanban.com/wordpress/thu-thuat-wordpress/tuy-bien-nut-submit-trong-khung-comment-cua-theme-genesis.html)
- [Việt hóa dòng chữ read more trong Genesis child theme](https://wpcanban.com/wordpress/thu-thuat-wordpress/viet-hoa-dong-chu-read-more-trong-genesis-child-theme.html)

## Cách chèn code snippet tùy biến

Tất cả đều được chèn vào file `functions.php` của Genesis Framework hoặc Genesis child theme mà bạn đang sử dụng. Các bạn cũng có thể sử dụng plugin [Code Snippets](https://wpcanban.com/wordpress/thu-thuat-wordpress/chen-code-php-vao-wordpress-voi-plugin-code-snippets.html) để chèn code nhằm tránh chúng bị xóa khi update theme.

Ngoài ra, các bạn có thể tham khảo thêm danh sách các code snippet tùy biến khác được Genesis Framework hỗ trợ [tại đây](https://my.studiopress.com/documentation/snippets/).

## Các code tùy biến khung bình luận

Sở hữu ngay một giao diện WordPress hoàn hảo (load nhanh, SEO tốt, bảo mật cao) với [Paradise child theme](https://wpcanban.com/mua-paradise-child-theme).

### Tùy biến comments link text

```
//* Tùy biến comments link trong Genesis
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter( $post_info ) {
	return '[ post_comments zero="Để lại một bình luận" one="1 Bình luận" more="% Bình luận" ]';
}
```

Nhớ xóa dấu cách (khoảng trắng) sau dấu `[` và trước dấu `]`. Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích. Ngoài ra, hiện tại Genesis cũng đã hỗ trợ tùy biến chúng bằng [post shortcodes](https://studiopress.github.io/genesis/basics/genesis-shortcodes/#post-shortcodes) trong *Appearance* => *Customize* => *Theme Settings* => *Singular Content* => *Entry Meta (above content)*.

### Tùy biến comments title text

```
//* Tùy biến comments title text trong Genesis
add_filter( 'genesis_title_comments', 'sp_genesis_title_comments' );
function sp_genesis_title_comments() {
	$title = '<h3>Bình luận</h3>';
	return $title;
}
```

Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích.

### Tùy biến trackbacks title text

```
//* Tùy biến trackbacks title trong Genesis
add_filter( 'genesis_title_pings', 'sp_title_pings' );
function sp_title_pings() {
echo '<h3>Trackbacks</h3>';
}
```

Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích.

### Tùy biến dòng chữ Speak Your Mind/ Leave a Comment

```
//* Tùy biến dòng chữ Speak Your Mind trong Genesis
add_filter( 'comment_form_defaults', 'sp_comment_form_defaults' );
function sp_comment_form_defaults( $defaults ) {
	$defaults['title_reply'] = __( 'Để lại một bình luận' );
	return $defaults;
}
```

Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích.

### Tùy biến author says text

```
//* Tùy biến author says text trong Genesis
add_filter( 'comment_author_says_text', 'sp_comment_author_says_text' );
function sp_comment_author_says_text() {
	return 'author says';
}
```

Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích.

### Tùy biến kích thước của Gravatar

```
//* Tùy biến kích thước của Gravatar trong Genesis
add_filter( 'genesis_comment_list_args', 'sp_comments_gravatar' );
function sp_comments_gravatar( $args ) {
	$args['avatar_size'] = 96;
	return $args;
}
```

Các bạn có thể sửa kích thước [Gravatar](https://wpcanban.com/tag/gravatar) ở dòng code số 4 theo ý thích. Đơn vị được tính bằng pixel.

### Tùy biến nút submit

```
//* Tùy biến nút Submit trong Genesis
add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
function sp_comment_submit_button( $defaults ) {
        $defaults['label_submit'] = __( 'Đăng bình luận', 'custom' );
        return $defaults;
}
```

Các bạn có thể sửa phần text ở dòng code số 4 theo ý thích.

### Thêm nội quy vào khung bình luận

```
//* Thêm nội quy vào khung bình luận trong Genesis
add_action( 'genesis_after_comments', 'sp_comment_policy' );
function sp_comment_policy() {
	if ( is_single() && !is_user_logged_in() && comments_open() ) {
	?>
	<div class="comment-policy-box">
		<p class="comment-policy"><small><strong>Nội quy bình luận:</strong>Viết nội quy bình luận của bạn vào đây.</small></p>
	</div>
	<?php
	}
}
```

Các bạn có thể sửa phần text ở dòng code số 7 theo ý thích.

### Loại bỏ các thẻ HTML được cho phép bên trên khung bình luận

```
//* Loại bỏ các thẻ HTML được cho phép bên trên khung bình luận trong Genesis
add_filter( 'comment_form_defaults', 'sp_remove_comment_form_allowed_tags' );
function sp_remove_comment_form_allowed_tags( $defaults ) {
	$defaults['comment_notes_after'] = '';
	return $defaults;
}
```

Hy vọng các code snippet bên trên sẽ phần nào giúp các bạn tùy biến khung bình luận của Genesis Framework và Genesis child theme một cách nhanh chóng, dễ dàng hơn.

*Nếu bạn thích bài viết này, hãy theo dõi blog của tôi để cập nhật những bài viết hay nhất, mới nhất nhé. Cảm ơn rất nhiều.* :)
