Wordpress how to load additional stylesheets (charts.css)

Viewed 52

I'd like to enqueue a stylesheet called charts.css & charts.min.css.

I'm not sure, why it's not working.

That's my added code in functions.php Wordpress:

function additional_stylesheets() {
    wp_register_style( 'custom01', get_template_directory_uri().'/assets/css/minified/charts.min.css'  );
    wp_enqueue_style( 'custom01' );
    wp_register_style( 'custom02', get_template_directory_uri().'/assets/css/unminified/charts.css'  );
    wp_enqueue_style( 'custom02' );
    }

add_action( 'wp_enqueue_scripts', 'additional_stylesheets' );

I tried in elementor to style a table but nothin' happened.

So I also tried to use:

<link rel="stylesheet" href="wp-content/themes/astra/assets/css/minified/charts.min.css">

but that's also not working.

Did I make a mistake somewhere?

I use the theme astra in WordPress.

The path is wp-content/themes/astra/.

After appending styleheets in WordPress I do not have to call them in html code anymore am I right?

1 Answers

You don't need to register them. Instead use the following code:

function additional_stylesheets() {
  wp_enqueue_style('charts_min_styles', get_theme_file_uri('/assets/css/minified/charts.min.css'), NULL, 1.2, false);
  wp_enqueue_style('charts_styles', get_theme_file_uri('/assets/css/unminified/charts.css'), NULL, 1.2, false);
}

add_action( 'wp_enqueue_scripts', 'additional_stylesheets' );

The code goes to the functions.php of your active theme or child them.

Related