• I want the header logo on my pages to change – often!
    I have 53 images prepared so would like to generate a body class such as w31 with this (and a css rule) the header image 31 will be displayed in week 31 – simple!

    My old theme (https://www.burgundy-report.com) worked fine with the following code in functions.php – but no new body class appears when I try it with twentysixteen – can anybody help?

    /* Adds 'week' id body-class */
    add_filter( '2016-br_body_class', 'my_body_class' );
    function my_body_class( $class ) {
    global $wp_query;
    
    $time = time() + ( get_option( 'gmt_offset' ) * 3600 );
    $class .= ' w' . gmdate( 'W', $time );
    
    if ( is_page() && $wp_query->post->post_parent )
        $class .= ' parent-' . $wp_query->post->post_parent;
    
    return $class;
    }
  • The topic ‘adding a (time) custom body class to twentysixteen’ is closed to new replies.