• Resolved databell96

    (@databell96)


    A little confusing, but I have three column site with two sidebars. One to the left and right of the main content area. I created the extra sidebar in my functions.php like this:

    // Register extra sidebar
    function mytheme_widgets_init() {
        register_sidebar( array(
            'name' => __( 'Extra Sidebar', 'tto' ),
            'id' => 'sidebar-4',
            'description' => __( 'The Left Sidebar. Displayed on all but full width and homepage template.', 'mytheme' ),
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget' => "</aside>",
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
        ) );
    }
    add_action( 'widgets_init', 'mytheme_widgets_init' );
    
    // Add child theme body class
    function mytheme_body_class( $classes ) {
    
         if( ! is_page_template() )
              $classes[] = 'custom-layout';
    
        return $classes;
    }
    add_filter( 'body_class', 'mytheme_body_class' );
    /* Flush cache when post is saved */

    Great. Obviously it works. It adds a style to the end of my body tag called ‘custom-layout’.

    However, I also created a duplicate of the Page template specifically for downloading files. On that one, the custom-layout style is not added to the body tag and I can’t seem to figure out why that is. What do I need to do to make this extra style appear inside of that tag?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding a style to the body tag from a custom template’ is closed to new replies.