Site logo

Archived topic

GPP / Child Theme / Stylesheet overwrite

22 replies · Started by Jan on July 14, 2021

Viewing posts 16–23 of 23

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

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

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. :)

Hi Elvin,

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

Many thanks for your great support.

Cheers,
Jan

Nice one. No problem. :D

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

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

This archived topic is closed to new replies.