Home > CMS Tutorial > WordPress > body text

How to set Chinese font in wordpress

Release: 2019-07-15 09:39:34
Original
3875 people have browsed it

How to set Chinese font in wordpress

The method to set Chinese fonts in WordPress is as follows:

Add the following code to the functions.php template file of the current theme:

function custum_fontfamily($initArray){
   $initArray['font_formats'] = "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';";
   return $initArray;
}
add_filter('tiny_mce_before_init', 'custum_fontfamily');
Copy after login

The default TinyMCE editor of WordPress does not have the font selection function, so you need to add the following code to the functions.php template file:

function enable_more_buttons($buttons) {
$buttons[] = 'styleselect';
$buttons[] = 'fontselect';
return $buttons;
}
add_filter("mce_buttons", "enable_more_buttons");
Copy after login

For more WordPress related technical articles, please visit wordpress tutorial column for learning!

The above is the detailed content of How to set Chinese font in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template