Roots Discourse

Load specific css y javascript

sage9
#1

In sage I can load specific javascript files. WordPress allows to load css by template implemented the function is_page_template (). I have a virtual page, which is not a type of content.
How can I load css and javascript with sage in a virtual page created with the filter generate_rewrite_rules?

Thanks for the help

0 Likes

#2

Hey @helgi - see if instead of checking for the page template you can check for whatever query vars, etc., your rewrite rule is working off of.

0 Likes

#3

Greetings @mmirus. I did it in the following way in the file setup.php:

global $wp_query;

if (isset($wp_query->query_vars['rents'])) {
	wp_enqueue_style(
		'sage/styles.css',
		asset_path('styles/style.css'),
		false,
		null
	);
}

Thanks for the suggestion

1 Like