Your logic is basically correct. You’re just missing a '
in your wp_dequeue_style() function.
Also, wp_dequeue_style()
only accepts one argument: the handle of the script/style you want to dequeue. You don’t need to pass the url. So your code would need to look like:
if ( is_page_template( 'specific-template.php' ) ) {
// Remove Site-wide CSS
wp_dequeue_style( 'generic styles' );
// And this would enqueue the unique css
wp_enqueue_style( 'unque to this template css', get_template_directory_uri() . '/css/unique-to-this-template.css', array(), '1.0');
}
You’ll also need to make sure that this code is hooked after the original style is enqueued.
If this is all your CSS from the same theme though (and not a child theme), then I’d suggest a different approach: Rather than dequeueing a specific style, just selectively enqueue it:
if ( is_page_template( 'specific-template.php' ) ) {
wp_enqueue_style( 'unque to this template css', get_template_directory_uri() . '/css/unique-to-this-template.css', array(), '1.0' );
} else {
wp_enqueue_style( 'generic styles', get_stylesheet_uri(), array(), '1.2' );
}