[Resolved] Display footer widget area only on Blog page

Home Forums Support [Resolved] Display footer widget area only on Blog page

Home Forums Support Display footer widget area only on Blog page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #313938
    Tim

    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

    #313983
    Tom
    Lead Developer
    Lead Developer

    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.

    #314012
    Tim

    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/

    #314019
    Leo
    Staff
    Customer Support

    Hi Tim,

    Can you first make sure that you clicked “Save changes and activate” on the snippet?

    Thanks and let us know 🙂

    #314024
    Tim

    I just re – “Save changes and activate” still no luck

    #314028
    Leo
    Staff
    Customer Support

    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;
    
     }
    #314030
    Tim

    Hello Leo,

    That worked!

    Thanks

    #314033
    Leo
    Staff
    Customer Support

    Glad we could help 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.