Techiio-author
Started by Marrine MorelSep 15, 2021

Open
Change Stylesheet in child theme on click

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

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

You must be Logged in to reply
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance