You’re on the right track, but you need to know the stylesheet’s ID. It’s not necessarily the same as the stylesheet’s filename.
Check the generated source of your page (ie, load the page up in a browser and View Source). Find the <link>
tag that’s loading the stylesheet. If it’s been properly enqueued for WordPress, it should look something like:
<link
rel="stylesheet"
id="your-stylesheet-id-css"
href="https://example.com/path/to/your-stylesheet.css"
/>
You need to take the value in the id
attribute and trim the -css
from the end.
So, in my example, you’d need:
add_action( 'wp_enqueue_scripts', 'wpse_382138_unload_css', 9999 );
function wpse_382138_unload_css() {
wp_dequeue_style( 'your-stylesheet-id' );
}
…changing your-stylesheet-id
to the value you find in your page’s generated source code.