- This topic has 5 replies, 3 voices, and was last updated 3 years, 11 months ago by David.
-
AuthorPosts
-
May 24, 2020 at 5:26 am #1299136Alan
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…
May 24, 2020 at 6:47 am #1299210DavidStaffCustomer SupportHi there,
you can use the Blog Options filter to conditionally change the number of columns:
https://docs.generatepress.com/article/option_generate_blog_settings/
And you can use the Layout Element to disable the Sidebar
https://docs.generatepress.com/article/layout-element-overview/
May 24, 2020 at 9:01 am #1299448AlanDavid:
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.
Thanks,
May 24, 2020 at 4:04 pm #1299778TomLead DeveloperLead DeveloperHi 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/
May 26, 2020 at 3:08 pm #1302675AlanWhat would be the function if I am displaying my posts on the blog page, rather than the home page?
May 27, 2020 at 12:42 am #1303078DavidStaffCustomer SupportIn Tom’s code you would change:
is_front_page()
to
is_home()
-
AuthorPosts
- You must be logged in to reply to this topic.