• wolfgegenlicht

    (@wolfgegenlicht)


    Hey there,

    I’m using the twenty-twenty-four theme with a child theme (it’s still blank) and got the following problem.

    I was working on the page, installed fonts via FSE and google fonts.

    Then I changed the domain from non-www to www through the database.

    So basically from

    https://example.com

    to

    https://www.example.com

    Now I get an CORS error because in the CSS that gets inserted into the <head>, the old non-www domain is referenced.

    So it currently says something like:

    @font-face{font-family:Outfit;font-style:normal;font-weight:100;font-display:fallback;src:url(‘https://example.com/wp-content/uploads/fonts/QGYyz_MVcBeNP4NjuGObqx1XmO1I4TC0C4S-EiAou6Y.woff2&#8217;) format(‘woff2’);}

    instead of

    @font-face{font-family:Outfit;font-style:normal;font-weight:100;font-display:fallback;src:url(‘https://www.example.com/wp-content/uploads/fonts/QGYyz_MVcBeNP4NjuGObqx1XmO1I4TC0C4S-EiAou6Y.woff2′) format(‘woff2’);}

    How can I actually change/update the path? I figured this doesn’t work through the database.

    So right now I’m working with a workaround…

    function replace_font_urls_in_css_output() {
    ob_start(function ($buffer) {
    // Replace non-www URLs with www URLs in the CSS output
    return str_replace(‘https://example.com&#8217;, ‘https://www.example.com&#8217;, $buffer);
    });
    }

    // Start output buffering before content is sent to the browser
    add_action(‘wp_head’, ‘replace_font_urls_in_css_output’, 1);
    add_action(‘wp_footer’, ‘replace_font_urls_in_css_output’, 1);

    Any idea, if there’s a native way to update the font path as well?

    Cheers
    Wolf

Viewing 1 replies (of 1 total)
  • I did a domain switch just like you but from www. to .

    I posted an issue a couple days ago because I’m getting errors via the Gutenberg plugin. I read docs on this site which state we don’t need the plugin to use blocks. However, there are a number of blocks I have inserted which rely on the Gutenberg plugin so I’m confused how it’s built into wordpress core. Other plugins for special blocks I understand.

    So basically if I try to edit a page the template loads and I cant edit a page. I disable Gutenberg and I can edit pages, but a bunch of blocks don’t display because the rely on Gutenberg (supposedly via Core?). So with the Gutenberg plugin enabled I can edit templates only. With it disabled I can edit pages but many blocks don’t show.

    Anyway I check my official urls in the DB in wp_options and under settings but all seems correct addressing for my scheme.

    I really wonder if the addressing goofs things up so much. (I migrated to a new server instance.)

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.