How to register an external style in the functions of wordpress?

Asked

Viewed 14 times

0

I’m having a hard time registering this style library: https://fonts.googleapis.com/css?family=Rajdhani functions of wordpress. Can help me?

1 answer

0

You can make use of the following function:

wp_enqueue_style( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, string $media = 'all')

In $deps, you need to pass an array of already registered styles that the current style depends on, so you need to register this css and then record your page style and configure the source as dependency on page style.

Example:

wp_enqueue_style('fonts', 'https://fonts.googleapis.com/css?family=Rajdhani');
wp_enqueue_style('main', '/file/path/', ['fonts']);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.