Brett
Brett

Reputation: 20049

Replacing TinyMCE fonts within WordPress editor - default fon't won't go away

I'm trying to replace the list of available fonts shown in WordPress' editor so that it only shows relevant fonts for the site, but even though I only include two custom fonts in the list the default one still shows up, that being "Georgia".

However, it's weird that it doesn't show up as a "selectable option", as in, it's the first option, but doesn't show in the actual dropdown.

My code:

add_filter('tiny_mce_before_init', 'blm_load_custom_fonts');

function blm_load_custom_fonts($init) {
    $init['font_formats'] = 'Poppins=Poppins, sans-serif;Tex Gyre Adventor=Tex Gyre Adventor, sans-serif';
    return $init;
}

Here is what I see:

enter image description here

How can I get rid of Georgia and make "Poppins" the default?

Upvotes: 0

Views: 209

Answers (1)

Michael Fromin
Michael Fromin

Reputation: 13746

When you load content into TinyMCE that select list will show the font in use where the cursor is located. If you click to see the content of the select list that should only show you the fonts you have configured to be an option.

It is hard to tell from your screenshot but it looks like the default text in the editor is indeed Georgia font?

This is how TinyMCE works and you can't disable that behavior.

UPDATE: To address your question on the "default" font. I would suspect WordPress allows you to determine the default font in use while creating content. There is a configuration setting for TinyMCE called content_css that allows you to pass in CSS that determines how things are rendered. Guessing WordPress already uses some sort of CSS (possibly theme related) that you would need to modify to change the default.

Upvotes: 1

Related Questions