Custom scss file in /layouts that only executes on a specific page

I am trying to find on the documentation a way to have a custom scss that only loads on a specific page. For example, I have a page called mysite.com/testimonials-and-reviews and I want to be able to just have a specific set of scss rules for that particular page. So I want to create my scss called _testimonials.scss on /layouts but how would I be able to load that scss when I load “mysite.com/testimonials-and-reviews
Any part on the documentation on how to that?

wp_enqueue_style() can be applied conditionally, i.e. to enqueue a specific CSS file only on a certain page.

like @alwaysblank said, you’ll need to set up an enqueue for your review page, like this:

//if the page is a custom template
if( get_page_template_slug() == 'views/template-reviews.blade.php') {
  wp_enqueue_style('sage/review', asset_path('style/review.css'), false, null);
}

When I did this, I used a simple CSS file, and didn’t use SCSS. There isn’t a way out of the box to add a second compile. You might be able get it working if you update the resources/assets/config.json to include a new entry, but i’m not entirely sure.

This topic was automatically closed after 42 days. New replies are no longer allowed.