• Hello

    would it be possible to assign dark mode automatically to a category page and all its articles ? Using a function or by modifying the theme ?

    tks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Oliver

    (@umik)

    so just to add , i ve found this code in the js customizer . It seems to add the dark mode class in the body tag, which happens when i tick the checkbox in the theme settings. But whatever i change he ( let s say i replace dark-mode by testthis ) nothing happens

    // Dark Mode

    ? ? wp.customize( 'hamilton_dark_mode', function( value ) {

    ? ? ? ? value.bind( function( newval ) {

    ? ? ? ? ? ? if ( newval == true ) {

    ? ? ? ? ? ? ? ? $( 'body' ).addClass( 'dark-mode' );

    ? ? ? ? ? ? } else {

    ? ? ? ? ? ? ? ? $( 'body' ).removeClass( 'dark-mode' );

    ? ? ? ? ? ? }

    ? ? ? ? } );

    ? ? } );
    Theme Author Anders Norén

    (@anlino)

    Hi @umik,

    You can hook into the WordPress body_class filter to add the dark-mode class when viewing a specific category or a post that belongs to a specific category, but you’d need to do it with PHP in a child theme or a plugin.

    — Anders

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.