I have a sidebar. Till now I am calling this as
dynamic_sidebar( 'home-left-widget-area' );
and this shows data in
<li>. But I need data in
How to store values in array so I can use
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
echo data. Take a look at the
widget method of some of the default widgets, like this one.
You can't save that data to an array without writing your own function to process the widgets and using output buffering where the widgets themselves
echo content. And sidebars/sidebar-widgets are complicated. That is not an easy function to write.
Sidebars are not meant to do what you want to do and even if you got it working your markup would be broken since you would be shoving whole widgets into a
<select>. You'd have all kinds of things inside the
<select> menu that are not supposed to be there. Try pushing something like this through the w3c validator:
<select> <option> <div><p><em>Hi</em></p></div> <li> hello </li> </option> </select>
That is something like what you will get.
What you are trying to do is complicated and wrong and browsers may not parse the markup correctly enough to do what you expect it to do anyway. I'd bet they would not. Complicated chunks of block level content are not supposed to be inside a select menu.
You do not need markup in a select menu to have a responsive theme. You need to rethink what you are doing.