Change GeneratePress slideout menu width

tdrayson

A SnippetClub member was looking for a way to change the width of the GeneratePress slideout menu. Thankfully, GeneratePress has a built-in filter we can use to override this.

Snippet

Add the code below to functions.php or code snippet plugin.

PHP

        /**
 * Modifies the width of the slideout.
 *
 * This function changes the default width of the slideout panel. The default width is 265px.
 * Make sure to include the units
 *
 * @since 14/01/2024
 * @author Taylor Drayson
 *
 * @param string $width The current width of the slideout, default is '265px'.
 * @return string The modified width of the slideout
 */
function tct_slideout_width($width){
    return '300px';
}
add_filter('generate_slideout_width', 'tct_slideout_width', 10, 1);
      
Copy

You can return whatever width you want inside the function. The default size is 265px.

NOTE: Make sure you include the units for example px.

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise