Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Webfonts only load on home page.

Discussion in 'Misc WordPress Requests' started by catacaustic, Oct 11, 2017.

  1. catacaustic

    Guest

    Reply To: Webfonts only load on home page., by catacaustic

    That happens through a “feature” of HTTP that browsers all do.

    When you reference a file like that, it takes the file location from the current page URL. As an example from your case:

    Say your looking for the file /webfonts/font1.otf

    If your page is http://www.mysite.com the browser will look for the file at http://www.mysite.com/webfonts/font1.otf

    If your page is http://www.mysite.com/subpage the browser will look for the file at http://www.mysite.com/subpage/webfonts/font1.otf

    There’s two ways to get around this…

    First, you can use a full URL, eg src: url(http://www.mysite.com/web-fonts/AntarcticanMono-Bold.woff2);.

    Second, you can tell the browser to look in the site root folder by adding ./ to the files URL, eg: src: url(./web-fonts/AntarcticanMono-Bold.woff2);

    I’d suggest the second method.

    Be aware that this only happens because you’ve added the CSS style rules into teh pages themselves. If you were using a CSS stylesheet file instead the file location would be relative to the CSS file.

    Reply To: Webfonts only load on home page.
     
    #1

Share This Page

Web Hosting