Home WordpressWordPress cơ bản Thay đổi Copyright Footer Credit trong Genesis Theme

Thay đổi Copyright Footer Credit trong Genesis Theme

by admincp

Genesis sở dĩ được nhiều người yêu mến vì nó kế thừa nhiều thành phần có trong một website hoàn chỉnh. Vả lại tùy biến các thành phần thông qua toàn bộ hooks bạn không phải mất công đi tìm nội dung này định nghĩa ở file nào trong thư mục nào. Mọi thứ được chia nhỏ ra, muốn sửa một thành phần nào đó thì thêm hook và chỉ sửa nội dung có trong hook cho tính năng đó. Khác so với bạn phải đi chỉnh sửa một tính năng tại ví trí code cho toàn bộ tính năng chứa trong một file, điều đó rất dễ gây lỗi mà không biết gỡ kiểu gì.

Thay đổi nội dung Genesis Copyright Footer Credit

Ok, trong bài này mình sẽ hướng dẫn các bạn tùy biến nội dung copyright credit nằm ở footer của genesis child theme. Thêm đoạn code sau vào functions.php

<?php
//* Do NOT include the opening php tag
//* Customize the credits
add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
function sp_footer_creds_text() {
	echo '<div class="creds"><p>';
	echo 'Copyright &copy; ';
	echo date('Y');
	echo ' &middot; <a href="http://mydomain.com">My Custom Link</a> &middot; Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>';
	echo '</p></div>';
}

Kết quả phần footer đã đổi thành thế này:
tùy biến copyright credit genesis child theme

Mặc định thông tin copyright widget nằm ở bên góc phải của footer. Bạn thay đổi nội dung credit phù hợp với yêu cầu của bạn. Genesis Footer cũng cung cấp các shortcode cho bạn tạo nội dung footer của mình. Thay dòng “Copyright ©” ở trên bằng shortcode [ footer_copyright ] như dưới đây.

<?php
//* Do NOT include the opening php tag
 
//* Change the footer text
add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter');
function sp_footer_creds_filter( $creds ) {
	$creds = '[footer_copyright] &middot; <a href="http://mydomain.com">My Custom Link</a> &middot; Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>';
	return $creds;
}

Chú ý: nếu bạn copy shortcode trong bài thì bỏ dấu cách đi nhé.

Bạn cũng có thể sửa toàn bộ nội dung có trong footer, bao gồm nút back to top.

<?php
//* Do NOT include the opening php tag
 
//* Customize the entire footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'sp_custom_footer' );
function sp_custom_footer() {
	?>
	<p>&copy; Copyright 2012 <a href="https://www.hoangweb.com/">HoangWeb.COM</a> &middot; All Rights Reserved &middot; Powered by <a href="http://wordpress.org/">WordPress</a> &middot; <a href="http://khosachnoi.net">KhoSachNoi.NET</a></p>
	<?php
}

Xóa Genesis Copyright Footer Credit

Để thực hiện điều này, bạn sẽ xóa vùng footer area trong genesis child theme. Cũng sử dụng đoạn code này trong file functions.php nhé.

<?php
 
remove_action( 'genesis_footer', 'genesis_do_footer' );

Nếu bạn thích bài viết này, hãy ủng hộ chúng tôi bằng cách đăng ký nhận bài viết mới ở bên dưới và đừng quên chia sẻ kiến thức này với bạn bè của bạn nhé. Bạn cũng có thể theo dõi blog này trên TwitterFacebook

Liên hệ

Công ty chuyên Thiết kế website uy tín nhất Miền Bắc: http://vinastar.net

Hotline tư vấn: 0989 48 3456

Nguồn: Sưu tầm trên internet

You may also like

Leave a Comment