Archived topic
Remove footer from 404 page
10 replies · Started by Max on September 7, 2017
Hey Tom
I already found your post about removing side bar from 404 page using snippet and 404 conditional.
Snippet works just fine.
But how do I remove the footers from the 404 page.
Thanks in advance for your assistance.
Hi there,
Try this with the same conditional:
add_action( 'after_setup_theme','tu_remove_footer' );
function tu_remove_footer() {
remove_action( 'generate_footer','generate_construct_footer' );
}
I ran this, but it did not work:
add_action( 'after_setup_theme','tu_remove_footer' );
function tu_remove_footer() {
if ( is_404() )
remove_action( 'generate_footer','generate_construct_footer' );
return $layout;
}
Try this:
add_action( 'after_setup_theme','lh_remove_footer' );
function lh_remove_footer() {
if ( is_404() ) {
remove_action( 'generate_footer','generate_construct_footer' );
}
}
Nope does not work. Even after clearing cache.
In any event seems a bit much to have to run two separate snippets in my functionality plugin just to style the 404 page...
Can these to snippets be combined (the first one does not work) second one does:
REMOVE 404 FOOTER
add_action( 'after_setup_theme','lh_remove_footer' );
function lh_remove_footer() {
if ( is_404() ) {
remove_action( 'generate_footer','generate_construct_footer' );
}
}
REMOVE 404 SIDEBAR
add_filter( 'generate_sidebar_layout','tu_custom_search_sidebar_layout' );
function tu_custom_search_sidebar_layout( $layout )
{
// If we are viewing 404 message, set the sidebar
if ( is_404() )
return 'no-sidebar';
// Or else, set the regular layout
return $layout;
}
My 404 page is styled and resided in my child theme folder...perhaps that is the reason the remove footer snippet did not work?
Thanks in advance for your kind assistance.
Max
That snippet Leo provided should work - how are you adding the function?
You can always just use CSS:
.error404 .site-footer {
display: none;
}
Hey Tom
Thanks for your reply.
Is there css to also remove the sidebar.
I can then put everything in my child theme style sheet.
And to answer your question I was running the above snippets in my functionality plugin
Try this:
.error404 .sidebar {
display: none;
}
Thanks for that.
.error404 .sidebar {
display: none;
}
only problem is that the page is not full screen (it is when using the snippet).
What do I need to add to this css to ensure the 404 page is full screen (content no sidebars) ?
Kind Regards
Max
Hmm can you link me to a page?