Using custom fonts hosted on AWS S3 on Wordpress

I have fonts from typography.com that I went into production and uploaded to my AWS S3 Bucket for use on my Wordpress site. I did everything typography.com said, but fonts still don't display. Has anyone gone through this before and can point me in the right direction? I added the @import expression in style.css in my topic to the URL typography.com gave me. I also have a wp_enqueue function in functions.php that I uploaded to the S3 server.

 add_action( 'wp_head', 'my_fonts' );
function my_fonts(){ ?>
<link rel="stylesheet" type="text/css" href="//cloud.typography.com/7783912/761788/css/fonts.css">
<?php
}

Fonts are still not displayed. What am I doing wrong?

+4
source share
1 answer

- wp_enqueue_style. . 'wp_enqueue_scripts', 'wp_head':

/**
 * Proper way to enqueue scripts and styles
 */
function theme_name_scripts() {
    wp_enqueue_style( 'typography', '//cloud.typography.com/7783912/761788/css/fonts.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

, , .

+1

Source: https://habr.com/ru/post/1598952/


All Articles