enqueue several google fonts families in wordpress

To include Droid Serif font in wordpress, I use this code, which I am told is the proper way to enqueue google fonts for wordpress:

function googfonts() {
$query_args = array(
 'family' => 'Droid+Serif:400,400italic,700,700italic'
 );
wp_register_style( 'google-fonts', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
wp_enqueue_style( 'google-fonts' );
}
add_action( 'wp_enqueue_scripts', 'googfonts' );

If I want to add e.g. Roboto:300,400,500,700 to this, I guess I can simply copy the three lines, create a new variable and fill it with roboto and then do a new register + enqueue.

Read More

But is there a way to do it with less repetition, somehow adding roboto to the array of the existing $query_args?

Related posts

Leave a Reply