Add a font to WordPress via custom plugin

  1. Create a plugin file like GeoLiv.php


    /* Plugin Name: GeoLiv Custom Code Plugin
    Description: Place to insert custom code into WordPress
    Look at this post source - a plugin is re-writing what you see here
    */
    function add_font() {
    $font_script = <<<'EOD'
    <link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
    EOD;
    echo $font_script;
    }
    #add_action('wp_head', 'add_font');
  2. Compress to zip
  3. Login to WordPress and navigate to to your WordPress dashboard, and click “Plugins->Add New”
  4. Upload plugin.
  5. Activate plugin.
  6. Go to your WordPress dashboard and click “Appearance->Edit CSS”
  7. This will take you to your theme customization page where you can insert all the CSS you want. Now add the following:

    p {
    font-family: 'Roboto Slab', serif;
    }
  8. Font should be active.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.