plugins – get url from @import in inline style and enqueue

Question

In your function.php file you can add the following

add_action('wp_enqueue_scripts', 'bt_enqueue_fonts');
function bt_enqueue_fonts () {
    wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css?family=Muli:400,600,700,500&subset=latin');
}

If you want each page to have different enqueue you can wrap the function in a condition, like this.

add_action('wp_enqueue_scripts', 'bt_enqueue_fonts');
function bt_enqueue_fonts () {
    if (is_front_page()) {
        wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css?family=Muli:400,600,700,500&subset=latin');
    }
}

This will enqueue the fonts only for front page, you can add else if (...) for all your other pages as needed.

0
Uxair 3 weeks 2021-10-03T07:33:05-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse