First of all, I have created sidebars on the widget panel:
add_action( 'widgets_init', 'my_register_sidebars' );
function my_register_sidebars() {
register_sidebar(
array(
'id' => 'sidebar1',
'name' => __( 'Sidebar1' ),
'description' => __( 'The Sidebar 1.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
)
);
I have created a number of custom sidebar layouts. I want each of these layouts to be it's own widget, as an option like the default wordpress ones (e.g. archives, calendar, RSS, Search, Tag Cloud etc). So I can select which ones I want available for every site created.
Then depending on which sidebars I have made available I want the option for users (when creating / editing a page) to be able to choose from a dropdown sidebar options box, which layout they want on the relevant page - So this can then be called dynamically instead of having to call each layout specifically myself:
get_sidebar('$user-selected');
Apologies for waffling a bit, but any help is appreciated.
(p.s. I want to avoid using plugins)
Thanks, Matt.
Just use a custom field with a select box which displays all the available sidebars. Then in your page template check for the custom field value and output accordingly.