Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Different sidebar layout for different blog post pages

Home Forums Support Different sidebar layout for different blog post pages

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #142083
    Sharon Steely

    I use the latest posts as my home page. I used the customizer to set the layout for Blog Sidebar Layout to Content (no sidebars) which is what I want for the home page.

    For my archives and categories, I want the left sidebar to show. Since these aren’t technically “pages” I don’t see a way to edit to turn off global settings.

    Here is my home page currently:
    http://elnews-new.unm.edu/

    Here is a category page, which I want to display with the left sidebar:
    http://elnews-new.unm.edu/index.php/category/online/

    This is a dev site.

    Thanks for your help!

    #142097
    bdbrown

    Hi Sharon. You could set the default layout to left sidebar, then use this function in your child theme functions.php file to remove the sidebar on your home page:

    add_filter( 'generate_sidebar_layout','generate_custom_sidebar_layout' );
    function generate_custom_sidebar_layout( $layout ) {
        // If we are on the home page, no sidebar
        if ( is_home() )
            return 'no-sidebar';
    
        // Or else, set the regular layout
        return $layout;
     }
    

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    #142102
    Sharon Steely

    Thanks bdbrown! I just implemented your suggestion and it worked!

    I appreciate you sharing the code as-is. My knowledge of pHP is very limited.

    Thanks for your help!

    And thanks for writing an awesome theme Tom!

    #142108
    bdbrown

    Glad to help 🙂 If you’re interested in learning more about PHP, here are a couple of good tutorials to get you started:

    http://www.webmonkey.com/2010/02/php_tutorial_for_beginners/
    http://devzone.zend.com/6/php-101-php-for-the-absolute-beginner/

    #142113
    Sharon Steely

    cool, thanks.

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