Archived topic
footer disappeared
11 replies · Started by Ewa on November 30, 2021
Hello,
I have the following issue. Footer has gone from my blog archive pages. Few days ago it was there but now - I don't know why it totally disappeared.
Could you help me identify why that happened?
Hi there,
The only built-in method to disable the entire footer in the archive and blog pages is to use a layout element:
https://docs.generatepress.com/article/layout-element-overview/
https://docs.generatepress.com/article/layout-element-overview/#disable-element
If that doesn't help then try disabling all plugins and custom functions except for GP Premium to test
Hello Leo,
thank you. I have idenified the problem which was a following code snippet:
add_action( 'pre_get_posts', function( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
$query->set( 'cat', -54 );
}
} );
I added it to hide posts from specific category and it worked but at the same time it removed the footer from archive pages.
Do you know any other method to get the result whicg is hiding posts from a specific archive category?
I can't see how that would be the issue as it has nothing to do with the footer.
How are you adding the code?
I have added it via code snippet plugin. It is definitively the reason, because if I disable this particular snippet (not the plugin) the footer turns up
The snippet has nothing to do with the footer.
Can you try disable all plugins except GP Premium and Code snippet to test?
I do understand, but that is exactly what I did. First I disabled all the plugins to check one by one which one is causing the problem. Finally when I enabled all plugins again except for Code Snippets plugin and the footer came back.
Then I enabled the code snippets plugin (the footer has gone) and then disabled the particular snippet:
add_action( ‘pre_get_posts’, function( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
$query->set( ‘cat’, -54 );
}
} );
and the footer appeared again so it has nothing left what could cause the problem like the abive mentioned code.
Do you think I could change it somehow to get the same result but without harming the footer?
Hi there,
the category archive you linked to has the Loop removed - is that what you added that snippet for ?
Hello David,
yes exactly. The aim was to remove the posts loop because I want to add them by myself (using different layout)
Try this function instead:
add_filter( 'generate_do_template_part', function( $do ) {
if ( is_category( '54' ) ) {
return false;
}
return $do;
} );
David, thank you very much. This code works perfectly - removes the posts loop but keeps the footer.
Thanks a lot!
Glad to hear that