Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Resolved] Enqueuing to create child themes with GP Premium

Home Forums Support [Resolved] Enqueuing to create child themes with GP Premium

Home Forums Support Enqueuing to create child themes with GP Premium

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #159743

    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?

    Lead Developer
    Lead Developer

    Hi 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' );

    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 πŸ™‚


    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!

    Lead Developer
    Lead Developer

    So 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/


    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; }
    Lead Developer
    Lead Developer

    Ah, get rid of this line:

    @import url("../generatepress/style.css");

    That should do it πŸ™‚


    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.

    Lead Developer
    Lead Developer

    A 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


    Thanks, Tom! I appreciate your help!

    Lead Developer
    Lead Developer
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.