- This topic has 22 replies, 3 voices, and was last updated 1 year, 5 months ago by Jan.
-
AuthorPosts
-
December 4, 2021 at 4:38 pm #2038596TomLead DeveloperLead 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' );
December 5, 2021 at 11:53 am #2039281JanHi 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,
JanDecember 5, 2021 at 8:30 pm #2039547ElvinStaffCustomer SupportHi 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#L39Can 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()
, andwp_enqueue_style()
are the recommended way of adding scripts/styles by WordPress. ๐December 6, 2021 at 2:38 am #2039727JanHi Elvin,
I have tried the revised php an it is working well.
Many thanks for your great support.
Cheers,
JanDecember 6, 2021 at 6:29 pm #2040633ElvinStaffCustomer SupportNice one. No problem. ๐
November 3, 2022 at 3:18 pm #2400698JanHi 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,
JanNovember 4, 2022 at 7:16 pm #2402221TomLead DeveloperLead DeveloperCSS 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/isOjzNgVYmcQNovember 7, 2022 at 2:56 pm #2405426JanThanks, Tom. I’ll pass that on the MP support.
-
AuthorPosts
- You must be logged in to reply to this topic.