Trước hết, có một số cách làm để thay đổi font chữ hiển thị trong back-end của website WordPress (wp-admin), bài viết dưới đây hướng dẫn bạn thay đổi bằng phương pháp “Chèn font từ Google Font vào file function.php”.
File: function.php, nằm trong thư mục /themes/
Path: /wp-content/themes/[tên theme của bạn]
Copy và dán đoạn code này vào file function.php, và trước dấu kết thúc ?> php.
// WordPress Custom Font @ Admin Frontend Toolbar
function custom_admin_font_frontend_toolbar() {
if(current_user_can('administrator')) {
echo '<link href="https://fonts.googleapis.com/css?family=Rubik:400,700&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">' . PHP_EOL;
echo '<style>#wpadminbar *:not([class="ab-icon"]){font-family:"Rubik",sans-serif !important;}</style>' . PHP_EOL;
}
}
add_action( 'wp_head', 'custom_admin_font_frontend_toolbar' );
// WordPress Custom Font @ Admin Login
function custom_admin_font_login_page() {
if(stripos($_SERVER["SCRIPT_NAME"], strrchr(wp_login_url(), '/')) !== false) {
echo '<link href="https://fonts.googleapis.com/css?family=Rubik:400,700&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">' . PHP_EOL;
echo '<style>body{font-family:"Rubik",sans-serif !important;}</style>' . PHP_EOL;
}
}
add_action( 'login_head', 'custom_admin_font_login_page' );
Trong đó, bạn hãy thay đổi font trong đoạn mã trên thành font mà bạn mong muốn bằng cách Replace font “Rubik” bằng tên font mà bạn mong muốn.