[Resolved] Change column count for specific category

Home Forums Support Change column count for specific category

This topic contains 3 replies, has 2 voices, and was last updated by  Leo 4 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #644274

    Dan

    Hi
    I am trying to change to a 1 column blog layout for 2 specific categories.
    The problem is that it causes all categories to have 1 column.
    I have set 3 columns in the customizer.
    This is showing up correctly with 1 column (category 183):
    https://www.golancoalition.org/recent-developments_en/

    This category is showing incorrectly (1 column instead of 3):
    https://www.golancoalition.org/publications/

    This is the code I used in the functions file:

    add_filter( 'generate_blog_get_column_count','generate_custom_column_count' );
    function generate_custom_column_count(){
        if ( is_category( '183' ) ){
            return 100;
        }
        if ( is_category( '185' ) ){
            return 100;
    }
        // Or else, return the default
        return $count;
    }
    

    Removing this function brings back 3 columns for all categories.

    Thanks,
    Dan

    GeneratePress 2.1.3
    GP Premium 1.6.2
    #644394

    Leo Customer Support

    Hi there,

    There are mistakes in the code. Try this instead:

    add_filter( 'generate_blog_get_column_count','lh_category_column_count' );
    function lh_category_column_count( $count ) {
        if ( is_category( array( 183, 185 ) )  ) {
            return 100;
        }
    
        return $count;
    }

    Note that you didn’t specify which variable it should return in the this line:
    function generate_custom_column_count()

    #644834

    Dan

    Thanks Leo,
    That did it.

    Dan

    #645011

    Leo Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.