Skip to content

Instantly share code, notes, and snippets.

@generatepress
Last active April 14, 2020 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/9fe7ed28e64ced5ef40d to your computer and use it in GitHub Desktop.
Save generatepress/9fe7ed28e64ced5ef40d to your computer and use it in GitHub Desktop.
Change the sidebar widths depending on page
add_filter( 'generate_right_sidebar_width','generate_right_sidebar_width_custom', 50 );
function generate_right_sidebar_width_custom()
{
if ( is_page( 'page-slug' ) ) {
return '20'; // 20% for yourURL.com/page-slug
}
if ( is_page( 'another-slug' ) ) {
return '30'; // 30% for yourURL.com/another-slug
}
// If neither of the above are true, return your default value
return '25'; // 25% or whatever your default is
}
add_filter( 'generate_left_sidebar_width','generate_left_sidebar_width_custom', 50 );
function generate_left_sidebar_width_custom()
{
if ( is_page( 'custom-slug' ) ) {
return '50'; // 50% for yourURL.com/custom-slug
}
if ( is_page( 'one-more-slug' ) ) {
return '15'; // 15% for yourURL.com/one-more-slug
}
// If neither of the above are true, return your default value
return '25'; // 25% or whatever your default is
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment