Resolved

webfont usage in Puro Premium

Puro Theme started by shreddie Jul 25, 2018 16 replies
shreddie Jul 25, 2018 · 5:55 pm #10163

Hi Andrew,

I want to add a webfont to use for the Site Title and Tagline, but cannot get it working. I put all of the webfont files, and .css with the @font-face declaration into the wp-admin/css directory, and linked to the stylesheet in the Home page HTML. I added this css to the Addition CSS in Puro Premium:

h1, h2 .site-title .site-description {
	font-family: 'CopperplateGothicStd33BC';
}

I followed the instructions carefully from font squirrel to generate my font kit and install it. But, it’s not rendering using the font.

the site is https://bowmanrestorations.com

thanks!
Bruce

Andrew Misplon Puro Jul 25, 2018 · 6:00 pm #10165

Almost there. The theme’s rule for the title is just a bit more specific. Try:

h1, h2, .site-header .site-branding h1.site-title, .site-header .site-branding h2.site-description {
	font-family: 'CopperplateGothicStd33BC';
}
shreddie Jul 25, 2018 · 6:25 pm #10167

That worked perfectly – thanks!! As always, I really appreciate your terrific support.

Bruce

Andrew Misplon Puro Jul 25, 2018 · 6:28 pm #10168

Super glad to hear that did the trick 🙂

shreddie Jul 30, 2018 · 4:37 pm #10187

Hi Andrew,

I added the link to the stylesheet containing the @fontface declaration to the HTML for each page, which was good for testing, but now I want to do it correctly.

I tried adding the @fontface declaration to the Customizing>Additional CSS but that didn’t work.

What’s the best way to add this:

<link rel="stylesheet" href="copperplatewebfont.css" type="text/css" charset="utf-8" />

So that it is used by all of the pages in my site, and survives theme updates?

Thanks!

Andrew Misplon Puro Jul 30, 2018 · 6:31 pm #10192

For sure, we can definitely get this update ready. Are you using a child theme? It’s ok if not.

shreddie Jul 30, 2018 · 7:01 pm #10193

No, I am not using a Child theme. I experimented with the Childify Me plugin, but once I created the child theme, it used the default puro look, and did not have all of my appearance customizations, so I switched back to my Puro Premium theme.

shreddie Jul 31, 2018 · 12:24 pm #10196

I used the Customizer Export/Import and now have a Child Theme with my settings, ready for the next step.

Thanks!

shreddie Jul 31, 2018 · 2:16 pm #10200

I also have the Code Snippets plugin installed and ready to use. Just not sure what php code to use in there… 🙂

Andrew Misplon Puro Jul 31, 2018 · 4:21 pm #10202

Sorry for the delay. Code Snippets isn’t necessary if you have a child theme. Edit your child theme functions.php file where you should find a function that looks something like this:

function puro_child_enqueue_parent_style() {
	wp_enqueue_style( 'puro-parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'puro_child_enqueue_parent_style', 8 );

Add to that function an enqueue for your new stylesheet, the final result would be:

function puro_child_enqueue_parent_style() {
	wp_enqueue_style( 'puro-parent-style', get_template_directory_uri() . '/style.css' );
	wp_enqueue_style( 'web-font', get_stylesheet_directory_uri() . '/copperplatewebfont.css' );
}
add_action( 'wp_enqueue_scripts', 'puro_child_enqueue_parent_style', 8 );

The line you are adding is:

wp_enqueue_style( 'web-font', get_stylesheet_directory_uri() . '/copperplatewebfont.css' );

This assumes you’ve inserted copperplatewebfont.css into the child theme. If you want to just add a new function to the child theme functions.php file, you could add something like:

/**
 * Enqueue custom styles.
 */
function puro_child_enqueue_custom_styles() {
	wp_enqueue_style( 'web-font', get_stylesheet_directory_uri() . '/copperplatewebfont.css' );
}
add_action( 'wp_enqueue_scripts', 'puro_child_enqueue_custom_styles', 8 );
shreddie Jul 31, 2018 · 4:54 pm #10203

Hi Andrew,

This is the first time I’ve done anything with a child theme. I’m not sure that I follow. my ‘puro child’ directory has only a functions.php file and a style.css file. The .php file is empty.

I used the Childify Me plugin to create my child theme, so maybe it didn’t do it the way you expected?

Sorry, but I think I need a bit more handholding for this part.

shreddie Jul 31, 2018 · 10:50 pm #10207

Hi Andrew,

I did download the zip. I then switched to the parent theme, deleted my current child theme, installed the new ZIP from Themes > Add New > Upload Theme. But now I’m not sure what to do next. Sorry, I am a novice at php.

Also, you said, this assumes you’ve inserted copperplatewebfont.css into the child theme. But I’m not sure how to do that.

Andrew Misplon Puro Aug 1, 2018 · 8:57 am #10208

Sure. You can either edit your child theme files via FTP, download them to your desktop and then use an editor like Sublime to change them and then upload them back to the server OR you can edit them via Appearance > Editor.

To copy copperplatewebfont.css to your child theme you have to use your hosting File Manager or a FTP client like FileZilla or FTP Duck. The child theme is located at /wp-content/themes/puro-child/.

Once at Appearance > Editor, edit functions.php and then head back to my instructions for how to proceed: https://purothemes.com/support/topic/webfont-usage-in-puro-premium/#post-10202.

shreddie Aug 1, 2018 · 9:31 am #10209

OK, thanks for the extra instruction.

I added my copperplatewebfont.css file to the /wp-content/themes/puro-child/ directory.

and then edited the functions.php, adding:

/**
 * Enqueue custom styles.
 */
function puro_child_enqueue_custom_styles() {
	wp_enqueue_style( 'web-font', get_stylesheet_directory_uri() . '/copperplatewebfont.css' );
}
add_action( 'wp_enqueue_scripts', 'puro_child_enqueue_custom_styles', 8 );

But it was not working – the font was not loading.

I Inspected the element, and my console had these errors:

copperplatewebfont.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
copperplategothicstd-33bc-webfont.woff:1 Failed to load resource: the server responded with a status of 404 (Not Found)
copperplategothicstd-33bc-webfont.ttf:1 Failed to load resource: the server responded with a status of 404 (Not Found)
copperplatewebfont.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

I installed the font files into the /wp-content/themes/puro-child/ directory, and it is now working!

Thanks for all of your help!!

17 posts