[Resolved] generate_right_sidebar_width

Home Forums Support [Resolved] generate_right_sidebar_width

Home Forums Support generate_right_sidebar_width

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1578828
    Randy

    For filters such as generate_right_sidebar_width, can I use the GP Premium Elements module to add these Hooks? And if so, which Hook do you apply it to and do you check the “Execute PHP” box?

    add_filter( ‘generate_right_sidebar_width’, function() {
    return 0;
    } );

    Would the above hide the right sidebar? Can’t get this to work.

    #1578943
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Our Elements module shouldn’t be used to execute functions like this – it’s purely a presentational tool.

    To add functions, you should use one of these methods: https://docs.generatepress.com/article/adding-php/

    You would need to use this filter to remove a sidebar: https://docs.generatepress.com/article/generate_sidebar_layout/

    More info here: https://docs.generatepress.com/article/sidebar-layout

    #1579006
    Randy

    Cool, good to know. Wish you guys also made a Code Snippets tool and/or added similar functionality to your GP Premium. Great products you have!

    In case it helps anyone else looking to do this, I used the Code Snippets plugin to hide the sidebar on static pages if the url parameter &myparam=myvalue is set:

    add_filter( 'generate_sidebar_layout', function( $layout ) {
    	$var = $_GET["myparam"];
    	if (
    		$var === "myvalue"
    		&&
    		is_page()
    	) {
    		return 'no-sidebar';
    	}
    	return $layout;
    } );
    #1580465
    Tom
    Lead Developer
    Lead Developer

    Awesome, thanks for sharing the code! 🙂

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