Archived topic
Archive layout is broken
5 replies · Started by Michael on March 14, 2022
Hi,
My archive layout is broken, but the blog is still fine.
I tried deactivating WP Rocket but it did not fix it.
Can you please have a look?
Thanks
Hi there,
looks like you have Pages in your post loop as well. You need to add the following PHP Snippet to tell Pages to use the Blog Columns:
add_filter( 'generate_blog_columns', function( $columns ) {
if ( 'page' === get_post_type() && ! is_singular() ) {
return true;
}
return $columns;
} );
Hi David,
Thanks for checking.
Can I somehow make sure that the blog layout only applies to the blog and the author archive uses the default layout?
Thanks
You can use the option_generate_blog_settings filter to conditionally apply all the Blog Options
https://docs.generatepress.com/article/option_generate_blog_settings/
For example this will disable Columns and Masonry on the Author archives:
add_filter( 'option_generate_blog_settings', 'db_custom_author_options' );
function db_custom_author_options( $options ) {
if ( is_author() ) {
$options['column_layout'] = false;
$options['masonry'] = false;
}
return $options;
}
great that worked. Thanks David
Glad to hear that!