Is There a Way to Enqueue the Theme’s Style Last After All the Other Styles?

[ad_1]

I’d like to override some of the plugins’ styles with my style.css. Is there a way to load it last among all the styles loaded by the theme? I’m currently doing this, but it’s loading the style.css of the theme twice:

// Add default styles and necessary JavaScript for all the pages
function ad_add_styles_and_scripts() {

// Use Inter from Google Fonts
wp_enqueue_style( ‘google-fonts’, “https://fonts.googleapis.com/css2?family=Inter:wght@100;400;700&display=swap” );

// Load the theme's style last
wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array(), null, 'all', 99 );

// Load main JavaScript file
wp_enqueue_script( ‘afterdark-navigation’ , get_template_directory_uri() . ‘/main.js’ );
}

// Hook to the scripts and style enqueueing
add_action( ‘wp_enqueue_scripts’, ‘ad_add_styles_and_scripts’, 99 );

  • This topic was modified 56 minutes ago by Samuel. Reason: Add missing line breaks

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer