[Support request] One Container for Blog Section and Single Posts Only

Home Forums Support [Support request] One Container for Blog Section and Single Posts Only

Home Forums Support One Container for Blog Section and Single Posts Only

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #470787
    Thomas

    I run a website with multiple custom post types. The default setting is set to separate containers. I would like to have the blog section and single post type to have only one container.

    I lifted the code below from another post but it’s only partially working. I seem to be missing something.

    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() || is_single() ) {
    $wp_classes = array_diff( $wp_classes, array( ‘one-container’ ) );
    } else {
    $wp_classes = array_diff( $wp_classes, array( ‘separate-containers’ ) );
    }

    // Add the extra classes back untouched
    return array_merge( $wp_classes, (array) $extra_classes );
    }

    #470919
    Leo
    Staff
    Customer Support

    Hi there,

    This way would actually be better: https://generatepress.com/forums/topic/container-style-only-in-blog/#post-300748

    Let me know if you need help with the full code 🙂

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