Cache Dynamic CSS

Cache Dynamic CSS

Note: This is a new option in GeneratePress 2.0

The option can be located in Customizer > General.

Many of your Customizer options write CSS for you, and output it to your pages. Instead of generating this dynamic CSS on every page load, we cache it in the database and serve the cached CSS instead. As you can imagine, this is a big performance boost.

On first load, the CSS will be cached and added to the database. Any time you save the Customizer options, the cache will bust and get updated with your new CSS.

Smooth Scroll

Smooth Scroll

Note: This option requires GP Premium.

Smooth scroll can be turned on in Customize > General. Turning this option on will allow you to add the smooth-scroll class to your links, which will force them to smooth scroll to their anchor points.

This option is also integrated with the sticky navigation, so the top of your anchor point isn』t hidden.

Regular Links

To add smooth scroll to regular links, simply give the  element the smooth-scroll class.

My Section

Menu Items

To add smooth scroll to menu items, give the menu item the smooth-scroll class. You can learn how to give menu items classes here.

Modifying duration

The following snippet allows you to speed up or slow down the built-in smooth scroll duration:

add_filter( 'generate_smooth_scroll_duration', 'tu_smooth_scroll_duration' );
function tu_smooth_scroll_duration() {
return 800; // milliseconds
}

SVG Icons

SVG Icons

Starting in GeneratePress 2.3, you can now choose to replace the standard font icons used throughout the theme with SVG icons. This removes the requests for the font files and also makes the icons slightly sharper.

The option can be modified in Customizer > General.

SVG icons is now the new default setting in new site installs.

Switching to Dynamic Typography

Switching to Dynamic Typography

Note: Dynamic typography is a new typography system being introduced in GeneratePress 3.1.0.

Dynamic Typography is a new type of typography system introduced in GeneratePress 3.1.0.

For sites updating to 3.1.0, our legacy typography system will remain the default to prevent any issues.

Switching your site to the new dynamic typography system is recommended. It』s faster, more user-friendly, and has a lot more features built-in.

To switch to it, you can go to Customize > General and check the Use dynamic typography system option.

If it』s your first time toggling this checkbox, we will try to automatically migrate your existing legacy typography settings to the new dynamic typography system. Once checked, you should review your dynamic typography settings in 「Customize > Typography」 to make sure everything migrated correctly.

If we detect the dynamic typography system is already in use (options already exist), no automatic migration will take place.

Global Colors Overview

Global Colors Overview

Note: This feature requires GeneratePress 3.1.0. or above.

You can find the Global Color options in Customize > Colors.

Once the Colors panel is open, you』ll see a list of Global colors and elements on your website.

Global Colors

By default, there are 7 colors added. Each color has a specific purpose.

From left to right:

Contrast – strongest text colorContrast 2 – lighter text colorContrast 3 – lightest text/border colorBase – dark background (strongest text still readable)Base 2 – lighter backgroundBase 3 – lightest background (white)Accent – main branding color

You can delete or rename these default colors. However, if you do you will need to update the color fields that are using the deleted/renamed color, as those fields will no longer have a value.

You can also add as many of your own colors as you like. Keep your global colors simple and minimal – these are colors you』re going to be reusing throughout your design and content. The beauty here is that you can always switch up the colors to completely change the style of your website.

Contrast Colors

Your contrast colors are typically your text/border colors.

Base Colors

Base colors are typically your background colors. There should be enough contrast between these colors and your Contrast colors so your text is still readable.

Accent Colors

Your accent color(s) are the least used colors on your site. They』re meant to grab attention (links, buttons, special headings, etc…).

Pick Colors For Elements

Hover on the color option to know what each option is for.

Eg. Initial/hover/current color options can be picked individually for primary navigation』s background and text.

To choose the color, simply click on one of the Global Colors or use a new color as you wish.

Remove Google Fonts

Remove Google Fonts

By default, Google Fonts won』t load if you don』t choose a Google Font in the customizer. If for some reason you still want to remove it. Try the PHP snippet below:

add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'generate-fonts' );
} );

If you wish to remove Google Fonts from the customizer as well, you can use the PHP snippet below: 

add_action( 'admin_init', function() {
add_filter( 'generate_google_fonts_array', '__return_empty_array' );
} );

Google Font Variants

Google Font Variants

In GPP 1.4, it』s now possible to choose the font variants you need for your chosen Google Fonts.

This is important, as each variant that has to load is an extra file your website has to load. Reduces the number of variants that load will speed your website up – sometimes considerably.

Let』s take Open Sans for example:

By default, we have all of those variants:

300 – super light300italic – super light, italicregularitalic600 – semi-bold600italic700 – bold700italic800 – super bold800italic

Now if we know in our content we』re only going to need a few of these, we can remove the ones we don』t need and our site will load faster. So, my site only needs:

300 – some light headlinesregular – all of my content700 – bold is definitely needed from time to time

Now, if I』m loading a different font just for my site title, I know that my site title is only going to be one style – light, bold, italic etc.. This means we can specify the one and only one variant that we need for this area.

Adding Local Fonts

Adding Local Fonts

Sometimes you may want to host a font locally, instead of using a service like Google Fonts. This article will take you through the steps to do this.

For the purpose of this article, we』ll be using Google Fonts. However, this process will work for any kind of font file you might have.

Downloading our font

So the first step is to download the font we want to use. For Google Fonts, this tool is incredibly useful.

At the top left, search for the font you want to download.

Once you click on your font, you』ll be taken to a page where you can choose your variants, and download the files.

When choosing variants, be sure to only check the ones you need. The more you check, the heavier your page will be.

The next step on the page is to copy our CSS, but we』re going to skip that for now, and head to step 4, which is downloading the files.

This will download a .zip file to your computer, which you can extract.

Uploading our font

Note: If you』re comfortable with uploading files to your server via FTP, you can skip this step and simply upload your font files to your child theme.

Now that we have our font files, we need to upload them to our server.

By default, the WordPress Media Library doesn』t allow us to upload font files. This is due to security concerns with some of these files.

However, we can temporarily allow these files to be uploaded by adding the below function to our website. Once we』re done, it』s best to remove this function.

add_filter( 'upload_mimes', function( $mimes ) {
$mimes['woff'] = 'application/x-font-woff';
$mimes['woff2'] = 'application/x-font-woff2';
$mimes['ttf'] = 'application/x-font-ttf';
$mimes['svg'] = 'image/svg+xml';
$mimes['eot'] = 'application/vnd.ms-fontobject';

return $mimes;
} );

Learn how to add PHP functions here.

Now we can upload our font files into the Media Library.

Now that our files are uploaded, let』s grab the File URL to one of them.

http://gp-test.local/wp-content/uploads/2019/02/open-sans-v15-latin-regular.woff2

Now, let』s remove the filename, and take note of the URL for the next step.

http://gp-test.local/wp-content/uploads/2019/02/

Using @font-face

Alright, we』re almost done! Now we need to reference our fonts in our CSS.

Let』s go back to our Google Fonts Helper website where we downloaded the font files, and head back up to step 3.

Under all of the CSS, you』ll see a field for the folder prefix. In there, we』re going to add the URL we took note of above.

Now above this field, copy all of the provided CSS, and add it to your website.

Learn how to add CSS here.

Take note of the font-family field in your CSS, we』re going to need this exact name below. You don』t have to keep what』s in there by default – you can change it to anything you want.

Adding Our font

Starting in GeneratePress 3.1, you can now add the local font in the customizer by inputting the font-family name without toggling on the Google Font option.

Dynamic Typography Overview

Dynamic Typography Overview

Note: This feature requires GeneratePress 3.1.0. or above.

You can find the Dynamic Typography options in Customize > Typography.

Please refer to this article if you would like to switch your existing site to use the new system.

Font Manager

Once the Typography panel is open, you』ll see the Font Manager.

The Google fonts list will show by clicking the Search fonts field. You can select a font from the dropdown list or type in the font name to search.

Once the font is selected, you can select the variants available.

If the selected font is a Google font, the Google font option will be toggled automatically.

If this Google font is installed locally, make sure this option is untoggled.

To add a font installed locally, enter the font name directedly in the Font family name field.

Google font-display

There』re 5 options in the dropdown list of Google font-display, to understand each option please check Google font-display.

Typography Manager

The typography manager section lets you assign fonts and manage typography for the elements of your site.

Once the element is selected, you』ll see the typography options available.

Typography Options

Responsiveness

Set different typography values for different devices by clicking the desktop/tablet/mobile icon.

Font family

This option controls the font family from the font list created in the Font Manager.

Font weight

This option controls the thickness of the character outlines relative to their height.

Text transform

None – No change to the font

Capitalize – The first letter of every word will be a capital

Uppercase – All letters will be capitalized

Lowercase – All letters will be lowercase

Font size

This option controls the size of the text.

Line height

This option controls the height of a line box.

Letter spacing

This option controls the horizontal spacing behavior between text characters.

Bottom margin

Some elements like body and headings have a bottom margin option which controls the spacing under the text.

Units

Units available: px, em, rem, % (for font size only). Please see this article for more info.