in my child functions.php I added a function that automatically changes the style based on a certain time. In order not to force users to these times, I would like to insert a link on the front end that users can use to change independently. A link for day mode and a link for night mode.
Unfortunately I have tried to find a solution but I have not found what is right for me.
This is my functions.php
add_action('wp_enqueue_scripts', 'enqueue_parent_theme_style');
function enqueue_parent_theme_style() {
if ( current_time('H') >= 7 && current_time('H') < 18) {
wp_enqueue_style('custom-styling', get_stylesheet_directory_uri() . '/style.css');
} else {
wp_enqueue_style('custom-styling', get_stylesheet_directory_uri() . '/style-dark.css');
}
}
0 Replies