[Resolved] GPP / Child Theme / Stylesheet overwrite

Home Forums Support [Resolved] GPP / Child Theme / Stylesheet overwrite

Home Forums Support GPP / Child Theme / Stylesheet overwrite

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #2038596
    Tom
    Lead Developer
    Lead Developer

    Not really sure that’s the best method, but you would replace line 5 with this:

    wp_enqueue_style( 'generate-style', get_template_directory_uri() . '/assets/css/main.min.css', array(), GENERATE_VERSION, 'all' );

    #2039281
    Jan

    Hi Tom,

    thanks for getting back. I added the following to the function.php:

    // MP courses - Enqueue GP stylesheet
    
    add_action( 'wp_enqueue_scripts', 'mepr_courses_enqueues', 110 );
    function mepr_courses_enqueues() {
    if( is_singular( array( 'mpcs-lesson', 'mpcs-course' ) ) ) {
    wp_enqueue_style( 'generate-style', get_template_directory_uri() . '/assets/css/main.min.css', array(), GENERATE_VERSION, 'all' );
    }
    }

    Any chance you can double check the PHP because it results in a error when reloading the site.

    Even more important to me, however, is your professional judgement regarding the method itself. May I ask you to elaborate how you would go about a “better way” to enqueue the stylesheet?

    Many thanks in advance,
    Jan

    #2039547
    Elvin
    Staff
    Customer Support

    Hi Jan,

    The code you’ve shared doesn’t have any syntax issues.

    Can you share a screenshot the error you’re getting?

    The line of code Tom provided is very similar to how the theme itself enqueues the style for the theme so it should work.
    https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/general.php#L39

    Can you try this?

    // MP courses - Enqueue GP stylesheet
    
    add_action( 'wp_enqueue_scripts', 'mepr_courses_enqueues', 110 );
    function mepr_courses_enqueues() {
    if( is_singular( array( 'mpcs-lesson', 'mpcs-course' ) ) ) {
        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
        $dir_uri = get_template_directory_uri();
        wp_enqueue_style( 'generate-style-mpcs', $dir_uri . "/assets/css/main{$suffix}.css", array(), GENERATE_VERSION, 'all' );
    }
    }

    wp_enqueue_scripts(), wp_enqueue_script(), and wp_enqueue_style() are the recommended way of adding scripts/styles by WordPress. ๐Ÿ™‚

    #2039727
    Jan

    Hi Elvin,

    I have tried the revised php an it is working well.

    Many thanks for your great support.

    Cheers,
    Jan

    #2040633
    Elvin
    Staff
    Customer Support

    Nice one. No problem. ๐Ÿ˜€

    #2400698
    Jan

    Hi Elvin,

    unfortunately, this very same issue popped up again after we migrated the single site to a Multisite Network. Even though we moved all the custom PHP to the new site, the stylesheets of the Theme are not being enqueued anymore on course pages (MemberPress plugin).

    I’m in touch with the MP support, but they are struggling to resolve this.

    Can you let me know which stylesheet carries the details about the primary font set up in the customizer/ typography/ font manager?

    Thanks,
    Jan

    #2402221
    Tom
    Lead Developer
    Lead Developer

    CSS created by the Customizer is added inline after the main theme stylesheet. It lives inside a <style> tag with this ID: https://www.screencast.com/t/isOjzNgVYmcQ

    #2405426
    Jan

    Thanks, Tom. I’ll pass that on the MP support.

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.