添加谷歌字体到Wordpress和管理标题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加谷歌字体到Wordpress和管理标题相关的知识,希望对你有一定的参考价值。

Add Google Lato Font link from Google Fonts to your website. It will add to your admin area also.
  1. function projectname_font_url() {
  2. $font_url = '';
  3. /*
  4. * Translators: If there are characters in your language that are not supported
  5. * by Lato, translate this to 'off'. Do not translate into your own language.
  6. */
  7. if ( 'off' !== _x( 'on', 'Lato font: on or off', 'projectname' ) ) {
  8. $font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
  9. }
  10.  
  11. return $font_url;
  12. }
  13.  
  14. function projectname_scripts() {
  15. wp_enqueue_style( 'projectname-lato', projectname_font_url(), array(), null );
  16. }
  17. add_action( 'wp_enqueue_scripts', 'projectname_scripts' );
  18.  
  19. function projectname_admin_fonts() {
  20. wp_enqueue_style( 'projectname-lato', projectname_font_url(), array(), null );
  21. }
  22. add_action( 'admin_print_scripts-appearance_page_custom-header', 'projectname_admin_fonts' );

以上是关于添加谷歌字体到Wordpress和管理标题的主要内容,如果未能解决你的问题,请参考以下文章

怎么解决Wordpress运行慢的问题

谷歌标签管理器在 wordpress 网站上导致 javascript 错误

谷歌浏览器第一次访问时不会显示字体(css3、wordpress)。 (仅在刷新时)

php WordPress谷歌字体功能

php WordPress谷歌字体集成

将字体真棒图标添加到完整的日历标题