[Resolved] Separate Containers just in the blog page

Home Forums Support [Resolved] Separate Containers just in the blog page

Home Forums Support Separate Containers just in the blog page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #217704
    Iván

    Hi Tim,

    There’s any way to separate containers only in the blog page like you did in your website?

    Thanks,

    Iván

    #217724
    Iván

    I would be very grateful if I could do that.

    Thanks,

    Iván

    #217779
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This site is all separate containers, the pages that aren’t are using the Sections add-on.

    However, you could try a function like this:

    add_filter( 'body_class', 'ivan_body_class', 100, 2 );
    function ivan_body_class( $wp_classes, $extra_classes )
    {
    	$wp_classes[] = 'one-container';
    	if ( is_front_page() ) {
    		$wp_classes = array_diff( $wp_classes, array( 'separate-containers' ) );
    	} else {
    		$wp_classes = array_diff( $wp_classes, array( 'one-container' ) );
    	}
    
        // Add the extra classes back untouched
        return array_merge( $wp_classes, (array) $extra_classes );
    }

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    #217882
    Iván

    Thanks,

    It works!

    Appreciate your help. Thanks again!

    #217911
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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