K
kml93
New Member
Hi there,
I'm looking for a solution to load an 'assets/styles/example.css' file for an element made with elementor only when this element is visible on the page. This element is a custom template with 302 ID.
I don't want to use elementor's 'Custom CSS' function because I'll need to deploy updates to this file on several website later.
I have access to my file functions.php.
My ID of post is 302. I try the condition is_page(),is_singular() and is not recognize.
```php
```
Actually I load in every page.
I'm looking for a solution to load an 'assets/styles/example.css' file for an element made with elementor only when this element is visible on the page. This element is a custom template with 302 ID.
I don't want to use elementor's 'Custom CSS' function because I'll need to deploy updates to this file on several website later.
I have access to my file functions.php.
My ID of post is 302. I try the condition is_page(),is_singular() and is not recognize.
```php
define('KS_CSS_PATH', get_stylesheet_directory_uri() . '/assets/css/');
if (! function_exists('load_example_style')):
function load_example_style(){// if (is_page(302)){wp_enqueue_style('ks-example-css', KS_CSS_PATH . 'example.css');
// }
}
endif;
add_action('wp_enqueue_scripts', 'load_example_style', 21);
```
Actually I load in every page.
Last edited: