Black Friday! Get up to 25% off GP Premium! Learn more ➝

[Resolved] Different sidebars for posts and pages

Home Forums Support [Resolved] Different sidebars for posts and pages

Home Forums Support Different sidebars for posts and pages

Viewing 15 posts - 1 through 15 (of 31 total)
  • Author
  • #493915

    The answers I have found when searching the forum aren’t what I had in mind. I thought the plugin Custom Sidebars would do what I want, but it does not.

    I would like to be able to have the site display one suite of widgets on the RIGHT sidebar if it is a page; else display another suite of widgets, again on the RIGHT, on all blog posts, categories, archives, whatnot.

    Right now, the stopgap measure, which I am NOT thrilled with, is using the right sidebar for pages and the left sidebar for blog stuff. This flip-flopping from left to right is annoying to users at the least.

    Is there a way to code for a Page sidebar and a Blog sidebar in functions.php and then load up whichever sidebar with the widgets desired? I would b e happy to pay for some help with this or donate to further GP development. That’s how important this issue is to me.

    The site in its current iteration is here:


    GeneratePress 2.0.2
    GP Premium 1.5.6
    Customer Support

    Hi there,

    Have you tried this one?

    It’s the one we’ve been recommending.


    That is the first one I tried and it won’t allow a different widget on the same side (in my case, the right side). So that didn’t work. It seemed, in theory, that Custom Sidebar widget would work, it allows you to specify clearly what post types go where, but it failed too.

    I just want to be able to have one right hand sidebar for pages and another right hand sidebar for blog stuff. I’ve coded that into functions files before, but cannot seem to get it to work with GP.

    My point being, I shouldn’t have to use a plugin, I should be able to plop some code into the functions.php file. I’ve tried several plugins and they simply won’t allow the right handed sidebar to be occupied by more than one suite of widgets. I think that is a GP limitation; it certainly isn’t a limitation in WordPress.

    Lead Developer
    Lead Developer

    It’s actually the way WordPress handles widgets – they’re meant to be global unless you register a completely new sidebar/widget area for every single page. You’ll notice the exact same experience using any theme – even the core Twenty-whatever themes released by WordPress.

    Content Aware Sidebars should be exactly what you’re looking for actually, it’s just a little confusing to get started.

    First, you would create a new custom sidebar – the one for pages for example:

    Your target sidebar would be the “Right Sidebar”.

    Then apply it using the conditions option – in your case it would be all pages. Check the second section here:

    There’s tons of other plugins as well for this. This one has been around for a long time, and has a more simple UI:

    It would be nice not to have to use a plugin for this, unfortunately WordPress simply doesn’t have that kind of functionality baked in. That’s why so many different plugins exist for it.

    Hope this helps!


    I will try it again, but as I said before, It didn’t work. I’ve been working with awp since 2004. I know a little bit about how it operates. I’ve always been able to create as many widget areas as I want, I just call them in the template. Of course, that’s when you “roll your own.”

    Just for fun, here is the code I inserted into the functions.php file of the GP child theme:

    function page_widgets_init() {
    	register_sidebar( array(
    		'name'          => 'Page Sidebar',
    		'id'            => 'page_sidebar',
    		'before_widget' => '<div>',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2>',
    		'after_title'   => '</h2>',
    	) );
    add_action( 'widgets_init', 'page_widgets_init' );

    And here is the portion of the page.php template that lives in the child theme directory: I modified only the line where I have **

    	 * generate_after_primary_content_area hook.
    	 * @since 2.0
    	 do_action( 'generate_after_primary_content_area' );

    And the page sidebar widget area does appear, as expected, but the pages are having none of it. πŸ™‚


    So I have targeted the right sidebar for pages. Now what happens when I want the blog stuff on the right? That is the limitation of every single stinking plugin I’ve tried. I should be able to modify the child theme’s page.php to add a custom sidebar. Which is what I was attempting to do above.

    Lead Developer
    Lead Developer

    Ah, I think you’re thinking about the dynamic_sidebar() function.

    You can definitely go that route with a child theme.

    Instead of the second snippet, add this file to your child theme named sidebar.php:

    You’ll see I just added a simple conditional in there to check if we’re on a page. If we are, it will display the sidebar you registered with your first snippet above.

    If not, it will do the regular logic.


    At long last. Squeeeee!!!!! But one final gotcha to change before things righted themselves. I had to go back into Customizations and change the blog sidebar presentation to content | sidebar. Changing it on the News Page (see screen dump) wasn’t enough.

    Content-aware sidebar plugin


    Resolved. Hitting the donate button now. πŸ™‚

    Lead Developer
    Lead Developer

    Index pages in WP (like the blog page) ignore metabox options, so that’s likely why you had to do it in the Customizer.

    Glad you got it working πŸ™‚


    Where is your donate link, Tom?

    Lead Developer
    Lead Developer

    Found it; thank you!!!!

    Lead Developer
    Lead Developer

    Wow, thank you so much! That’s super generous of you πŸ™‚

    Really appreciate it! As always, let me know if you have any other questions.


    It’s the least I could do! You spent at least an hour of your time helping me; I know your time is more valuable than mine! πŸ™‚

Viewing 15 posts - 1 through 15 (of 31 total)
  • The topic ‘Different sidebars for posts and pages’ is closed to new replies.