Archived topic
Display footer widget area only on Blog page
7 replies · Started by Tim on May 4, 2017
Hello,
I want to display footer widget area only on the Blog page, how to do this without having to check it off on every page or post?
Thanks
Hi Tim,
First, set the global setting to 0: https://docs.generatepress.com/article/footer-widgets/
Then add this function:
add_filter( 'generate_footer_widgets','tu_custom_blog_footer_widgets' );
function tu_custom_blog_footer_widgets( $widgets )
{
// If we are on the blog, set the number
if ( is_home() )
return '4';
// Or else, set the regular number
return $widgets;
}
Adding PHP: https://docs.generatepress.com/article/adding-php/
Replace the 4 with however many widgets you want to display.
Hello Tom, thanks for the snippet,
But can not get to work!
I have set the global widgets to 0 in
Customizing ▸ Layout > Footer
Have placed this in code snippit
add_filter( 'generate_footer_widgets','tu_custom_blog_footer_widgets' );
function tu_custom_blog_footer_widgets( $widgets )
{
// If we are on the blog, set the number
if ( is_home() )
return '2';
// Or else, set the regular number
return $widgets;
}
Nothing showing
http://greaterthanthesum.com/blog/
Hi Tim,
Can you first make sure that you clicked "Save changes and activate" on the snippet?
Thanks and let us know :)
I just re - “Save changes and activate” still no luck
Ahh that's actually just a regular page named blog.
Can you give this code a shot instead:
add_filter( 'generate_footer_widgets','tu_custom_blog_footer_widgets' );
function tu_custom_blog_footer_widgets( $widgets )
{
// If we are on the blog, set the number
if ( is_page( 'blog' ) )
return '2';
// Or else, set the regular number
return $widgets;
}
Hello Leo,
That worked!
Thanks
Glad we could help :)