WordPress.org

Forums

Highwind
[resolved] Remove Open Sans and add custom fonts (3 posts)

  1. AJ
    Member
    Posted 1 year ago #

    Just in case anyone else wants to remove Open Sans and add their own typography into the theme.

    Add the following in Functions.php:

    // remove Open Sans font
    add_action( 'wp_enqueue_scripts', 'my_deregister_styles', 100 );
    
    function my_deregister_styles() {
    	wp_deregister_style( 'open-sans' );
    }
    
    // add custom fonts
    add_action( 'wp_enqueue_scripts','highwind_add_myfonts');	
    
    function highwind_add_myfonts() {
    wp_enqueue_style( 'my-fonts', 'http://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Alegreya:700' );
     //add your own fonts here.
    }
  2. pabagan
    Member
    Posted 1 year ago #

    Thanks AJ. I tried that function and remove Open Sans stylesheet but also breaks styles from WP Top-bar admin.

    Very dissapointed for the default Open Sans loading!!

    This here worked for me.

    Bests!!

  3. AJD
    Member
    Posted 1 year ago #

    That is strange. It is working fine on one site, but not on another.
    Thanks for the solution, I'm going to paste it here:

    // Remove Open Sans that WP adds from frontend
    
    if (!function_exists('remove_wp_open_sans')) :
    function remove_wp_open_sans() {
    wp_deregister_style( 'open-sans' );
    wp_register_style( 'open-sans', false );
    }
    add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
    // Uncomment below to remove from admin
    // add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
    endif;

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic