Wordpress - Add Google Fonts to Wordpress and Admin Header


/ Published in: PHP
Save to your folder(s)

Add Google Lato Font link from Google Fonts to your website. It will add to your admin area also.


Copy this code and paste it in your HTML
  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' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.