Archived topic
get_sidebar() with Block Elements (sidebar type)
10 replies · Started by AMBTL on March 12, 2023
Hi,
I am building a site with GP, Meta Box and FacetWP.
In the conditional sidebars I need filters generated by FacetWP.
To create the loops I use Meta Box Views, and to make it work in Taxonomy Archives, I must choose "Replace the layout between header and footer" from the View settings. This, however, deletes the sidebar.
I have found out that adding the get_sidebar() function (as Meta Box proxy {{ mb.get_sidebar() }} ) to the template, adds the sidebar. But that only adds the default sidebar. The Display settings in the Block Element are not respected, Meta Box Views doesn't "see" the Block Element.
Are the sidebars created with Block Elements registered as proper sidebars, so that I could try get_sidebar('my-sidebar-id')? I looked for them in the database, but could not find them.
Or maybe there is some trick to force them to display them where needed?
Greetings,
Tom
Update: Something unexpected happened: I changed the Element settings to "right sidebar" and the block element appeared in the left sidebar... My layout is Sidebar/Content, so I am a little confused...
The body class is ".left-sidebar" and the widget area class is ".is-right-sidebar". I am glad it seems to work, but I am quite confused about what is happening.
Hello there,
That's odd indeed. Did you make any changes to the template files? Do all the sidebar hooks behave differently?
Reference: https://docs.generatepress.com/article/hooks-visual-guide/#posts-page
No, I didn't touch any GeneratePress template files. And yes, it doesn't matter if I replace the sidebar completely in Elements, or place it "after_right_sidebar_content". Basically, right is the new left :)
I only created a Meta Box Views template for the taxonomy archive, using Twig. And added the sidebar through "get_sidebar()", because it won't appear otherwise.
Do Elements sidebars have names/IDs which could be accessed through get_sidebar()?
Greetings,
Tom
Update: Unfortunately, even accepting that "right is the new left" doesn't work, because the element display conditions don't work. I have so far 1 sidebar for taxonomy term archive 1 and another sidebar for taxonomy term 2. The second sidebar should completely replace the sidebar (Element Type: right sidebar), but what it does is it merges with first sidebar, as if it were "after right sidebar content". So, it is not usable, the way it is now...
Hi there,
is it possible to see one of the pages with this issue ?
Hello David,
Can I send an All-In-One Migration backup file so that you can freely experiment with it?
Greetings,
Tom
Update: the sidebars no longer merge, it turned out the display condition wasn't saved correctly.
But still, the sidebars are not displayed in the right place. And I cannot have a dual sidebar setup. Changing the layout to Sidebar/Content/Sidebar enables only the Right Sidebar area, and the Left Sidebar area is not there in the page source, although the body class is "both sidebars". I would like to have 2 sidebars on some archives...
I just need to see the site. Is that possible ?
The link is in the private information below. The site is under construction and might not work well on small screens at the moment. I recommend viewing on a larger monitor.
Greetings,
Tom
Can you provide admin login credentials so we can take a closer look?
Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information