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.
sidebars_widgets
would not work for rendered widgets, and that sidebars are now widget block areas, and blocks can be inserted that are not widgets<div style="display:none;" id="my-hamburger-menu-widgets"><?php dynamic_sidebar('menu-sidebar'); ?></div>
then query for it in JS, remove it from the DOM, re-insert it inside the profile menu. Otherwise if what you've already done works then this is not optimising, this is micro-optimisation, which is a very bad thing. Directly reading the widget data from the database is very bad, and deprives widgets and themes of chances to use hooks and actions, and will break if the storage format changes. Use the provided APIs instead