[Resolved] Used different number of columns for Blog and Archive pages

Home Forums Support Used different number of columns for Blog and Archive pages

  • This topic has 5 replies, 3 voices, and was last updated 5 months ago by David.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #1299136

    I want to use two columnns with a sidebar for my main blog page and three columns without a sidebar for my category, tag, and author archive pages. Is this possible? In the customizer, there is only one columns setting…

    Customer Support

    Hi there,

    you can use the Blog Options filter to conditionally change the number of columns:


    And you can use the Layout Element to disable the Sidebar




    Please forgive me, but I am new to Generate Press and not a developer. I followed your instructions and created a snippet with the following code:

    add_filter( ‘option_generate_blog_settings’, ‘lh_custom_search_results_page_settings’ );
    function lh_custom_search_results_page_settings( $options ) {
    if ( is_search() ) {
    $options[‘read_more_button’] = false;
    $options[‘date’] = true;
    $options[‘categories’] = false;
    $options[‘tags’] = false;
    $options[‘comments’] = false;
    $options[‘infinite_scroll’] = true;
    $options[‘infinite_scroll_button’] = true;
    $options[‘masonry_load_more’] = ‘More search results’;
    $options[‘post_image’] = true;
    $options[‘post_image_position’] = ‘post-image-above-header’;
    $options[‘post_image_alignment’] = ‘post-image-aligned-center’;
    $options[‘column_layout’] = true;
    $options[‘featured_column’] = false;
    $options[‘masonry’] = false;

    return $options;

    It produced an error message as follows:

    The snippet has been deactivated due to an error on line 3:
    Cannot redeclare function lh_custom_search_results_page_settings.

    What should the code be for line 3? As previously stated, my goal is to have the archive pages return three columns while the main blog page remains at two columns.


    Lead Developer
    Lead Developer

    Hi there,

    Instead of that function, do this:

    add_filter( 'generate_blog_get_column_count', function( $column_width ) {
        if ( is_front_page() ) {
            return '50';
        return $column_width;
    } );

    That will make it so your home page has two columns, and the rest of your site will use the option set in the Customizer.

    As for the sidebar, the Layout Element is the best way to go: https://docs.generatepress.com/article/layout-element-overview/


    What would be the function if I am displaying my posts on the blog page, rather than the home page?

    Customer Support

    In Tom’s code you would change:




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