Ok, what a pity that there is no function for this.
I am now trying to solve this using user-defined fields, but I need to know which CSS file is responsible for the dark mode.
Could you let me know?
This is the code I am trying to work with so far:
function add_dark_mode_css_custom_field() {
if (get_post_meta(get_the_ID(), ‘dark_mode’, true) === ‘true’) {
wp_enqueue_style(‘dark-mode’, get_stylesheet_directory_uri() . ‘/dark-mode.css’);
}
}
add_action(‘wp_enqueue_scripts’, ‘add_dark_mode_css_custom_field’);