- This topic has 9 replies, 2 voices, and was last updated 10 years, 3 months ago by
Tom.
-
AuthorPosts
-
December 13, 2015 at 3:34 am #159743
NBC
The WordPress Codex officially deprecates the longstanding method of using child themes by importing the parent themes CSS.
But when I read the discussion linked above, it clearly states the following:
The correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php. You will therefore need to create a functions.php in your child theme directory. The first line of your child theme’s functions.php will be an opening PHP tag (<?php), after which you can enqueue your parent and child theme stylesheets. The following example function will only work if your Parent Theme uses only one main style.css to hold all of the css. If your theme has more than one .css file (eg. ie.css, style.css, main.css) then you will have to make sure to maintain all of the Parent Theme dependencies.
I said “clearly states,” but the only thing that’s clear about this is that it sets up the objective without ever explaining how to accomplish it. Because GP, and therefore GP Premium, uses multiple CSS files, how on earth do I go about creating a child theme using the currently recommended method?
December 13, 2015 at 10:44 am #159807Tom
Lead DeveloperLead DeveloperHi there,
GP actually does this for you, so you just need to create a child theme style.css file with the appropriate headings, and GP does the rest.
Here’s the snippet from GP:
if ( is_child_theme() ) : wp_enqueue_style( 'generate-child', get_stylesheet_uri(), true, filemtime( get_stylesheet_directory() . '/style.css' ), 'all' ); endif;It checks if a child theme is activated, and if it is, it enqueues the style.css file found in the child theme main directory.
Let me know if you need more info 🙂
December 13, 2015 at 12:32 pm #159830NBC
Except that none of my custom typography appears, except for the typeface selected in the header. The body copy shows up in a generic sans serif typeface, not the slab serif I chose for it.
I was assuming this stemmed from a failure to load whichever CSS file records the Typography selections in the Customizer, and that I needed to pursue the enqueuing method to assure that the rest of the CSS files loaded in.
I can’t show you a screenshot because I’m working locally under MAMP.
BTW, thanks as always for all you do to make this such an awesome theme!
December 13, 2015 at 12:47 pm #159834Tom
Lead DeveloperLead DeveloperSo when you choose a font in “Customize > Typography”, it’s not applying to the site?
Can you try #1 on this page?: https://generatepress.com/knowledgebase/debugging/
December 13, 2015 at 1:27 pm #159841NBC
I’m not using any non-GP plug-ins, so that debugging step doesn’t apply.
It was working before I enabled the child theme.
Here’s the entirety of the child theme’s style.css file content. The other two files in the child come from your basic child package, including a theme screenshot PNG and a functions.php file.
/* Theme Name: GeneratePress child Theme URI: http://generatepress.com Description: GeneratePress child theme Author: Thomas Usborne Author URI: http://edge22.com Template: generatepress Version: 0.1 Tags: two-columns, three-columns, one-column, right-sidebar, left-sidebar, fluid-layout, responsive-layout, custom-header, custom-background, custom-menu, custom-colors, sticky-post, threaded-comments, translation-ready, featured-images, theme-options, light, white, dark, black, blue, brown, gray, green, orange, pink, purple, red, silver, tan, yellow */ @import url("../generatepress/style.css"); .highlight-text { background-color:#FFFF00; }December 13, 2015 at 6:45 pm #159876Tom
Lead DeveloperLead DeveloperAh, get rid of this line:
@import url("../generatepress/style.css");That should do it 🙂
December 14, 2015 at 3:12 am #159930NBC
#brainfail
Urgh, thanks for rescuing me. I wish I could just edit the files in the child without having to deactivate it, delete it, and reupload it. <sigh> (slow computer)So now that I’ve revealed myself as the utter idiot I am, how about another question that’s apt to confirm the same classification? 😉
Is there any way to create custom styles in a child theme and reveal them in the Customizer so as to use typefaces other than the basics? As far as I can tell, the coding and syntax required for that task reaches far beyond the basics into astrophysical territory. IOW, way beyond my meager paygrade.
December 14, 2015 at 10:06 am #159971Tom
Lead DeveloperLead DeveloperA lot of places still say to add that @import line – totally not your fault 🙂
For the child theme question, it’s possible, but you’ll have to use some PHP.
More info here: https://generatepress.com/forums/topic/how-can-i-create-a-child-theme-that-comprehends-customizer-settings/#post-114781
December 14, 2015 at 2:22 pm #160030NBC
Thanks, Tom! I appreciate your help!
December 14, 2015 at 8:37 pm #160069Tom
Lead DeveloperLead DeveloperYou’re welcome! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.