Replace Fonts

[ad_1]

Hi everybody,

to this day i have not found a way to completely remove all fonts from the wordpress core and replace them with a single one. So no i looked into my source code in Dev Tools and found some fonts i want to replace. I have used this snippet but that doesn’t work, nothing is changed.

`function replace_text($text) {`

`$text = str_replace(‘font-family:Menlo,Consolas,monaco,monospace’, ‘font-family:Raleway’, $text);`

`$text = str_replace(‘font-family:Open Sans,Arial,sans-serif’, ‘font-family:Raleway’, $text);`

`$text = str_replace(‘font-family:Courier New,monospace’, ‘font-family:Raleway’, $text);`

`$text = str_replace(‘font-family:Open Sans,sans-serif’, ‘font-family:Raleway’, $text);`

`$text = str_replace(‘font-family:Open Sans,sans-serif’, ‘font-family:Raleway’, $text);`

`return $text;`

`}`

`add_filter(‘the_content’, ‘replace_text’);`

[ad_2]
2 Comments
  1. Not sure why you’re going down the PHP path. And simple CSS rule should do it. What are you trying to replace exactly?

  2. That won’t work. The_content refers to the content inside your posts, not your fonts. You will likely need to use wp_dequeue_style to disable them and then enqueue your own fonts.

    You likely aren’t using twentyfifteen theme so you’ll have to do some digging because we don’t know what theme you’re using, but that’s the idea

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer