Retrieve the whole widget sidebar and pass it inside an html

I am trying to pass the sidebar that I have in the shop, inside a side drawer that will have the filters. I have created the HTML/CSS and the js responsible for this to work. But I am trying to get the content of all the sidebar from the database and apply it inside my drawer. I am a bit of a junior in PHP and in WordPress development. So any guideline on how to achieve this would be appreciated. I am aware of the options table and that under sidebars_widgets i can find the content. But I can not retrieve this and apply it inside the HTML code.

Also, I don't want to use any plugins. So answers like this will not help. I am aware that there are some plugins that can create shortcodes of any widget in order to use them later inside any text or HTML, but I highly want to avoid them.

Topic php sidebar widgets Wordpress

Category Web


So after some tests, I finally got this working. Thanks to some guidelines from @Tom J Nowell I achieved to pass a sidebar inside a side-draw without the use of any plugin. What I was trying to achieve was very simple, as most of the WordPress themes out there have the sidebar below or on top of the main shop archive page. So the conclusion was simple as that

<div class="drawer-cont">
           <?php dynamic_sidebar('shop-sidebar'); ?> 
</div> 

Where ('shop-sidebar') was the name of my sidebar on the widgets' area. If someone else is in that position, then just simply try to add the name of your sidebar with the '-' in the spaces. As specified on the WordPress codex:

If your theme specifies the ‘id’ or ‘name’ parameter for its registered sidebars you can pass an ID or name as the $index parameter. Otherwise, you can pass in a numerical index to display the sidebar at that index.

So in other words, if your themes use the name parameter to register sidebars, you can pass the name of the sidebar with the dash in place of the spaces. In most cases, this will work.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.