Support » Themes and Templates » Twenty Twelve Child Theme Body Class?

  • Resolved Inspired Media


    Hi All,

    Currently I am working on a child theme for Twenty Twelve theme, where I have a custom made homepage. I first created this homepage, so it all looks good. But now when I add a widget to the sidebar, it changes the body class.

    <body class=”home page page-id-5 page-template page-template-startpagina-php logged-in full-width custom-font-enabled single-author”>

    <body class=”home page page-id-5 page-template page-template-startpagina-php logged-in custom-font-enabled single-author”>

    How do I fix this, so it doesn’t change body class on the homepage? The rest of the content pages on this side will all have a sidebar.

Viewing 4 replies - 1 through 4 (of 4 total)
  • paulwpxp


    Font hero

    You can remove the action in function.php or add your own, but there is no benefit in doing this, because you will mess up the layout for full-width page template and attachment page too.



    Forum Moderator

    you will need to compensate the change of the body_class in functions.php of your child theme, for the startpagina.php page template;


    function twentytwelvechild_body_class( $classes ) {
    	if ( is_page_template( 'frontpagina.php' ) )
    		$classes[] = 'full-width';
    	return $classes;
    add_filter( 'body_class', 'twentytwelvechild_body_class', 20 );

    Alchymyth, thanks alot, this fixed it!



    Font hero

    The point of body_class() is so that you can assign changes based on CSS classes, so in this case I find it a little unintuitive to filter the function instead of making use of classes that WP already made for you.

    It only needs 1 line of CSS targeting your class to make the page behave like .full-width.

    For example ( used in child theme’s)

    @media screen and (min-width: 600px) { .site-content {width:100%;}

    The thing that has to be done in function is changing the $content_width of this page to 960 if you care for the embed to be full width on this page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Twenty Twelve Child Theme Body Class?’ is closed to new replies.