Here comes the workaround solution discussed in the comments:
functions.php:
add_action( 'widgets_init', 'talfluxive_register_sidebars' );
function talfluxive_register_sidebars() {
// register five random widget areas
register_sidebars( 5, array( 'name' => 'Random Widget Area %d' ) );
// register two fixed widget areas
register_sidebars( 2, array( 'name' => 'Fixed Widget Area %d' ) );
}
sidebar.php
dynamic_sidebar( 'Fixed Widget Area 1' );
dynamic_sidebar( 'Random Widget Area ' . rand( 1, 5 ) );
dynamic_sidebar( 'Fixed Widget Area 2' );
This example code is very minimal and could be improved in many ways but it works and should serve as a good starting point.
PS: I really like the random widget idea. I will look for a better solution when I have more time. It’s a good plugin inspiration 🙂
Related Posts:
- Simple rich text editor in Text widget?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- How to enable edit button in the theme’s customize UI?
- How can I make my custom shortcode work in a Custom HTML Widget?
- Disable Specific Widgets on Selected Pages of a WordPress Website?
- How do I add a widget programmatically to a newly created site (WPMU) within a plugin?
- Override Widget class in plugins with custom plugin
- WordPress widget / plugin….fields not appearing in my widget
- Can I ignore caching of a plugin in W3 Total Cache? [closed]
- Why is the unrendered widget number `__i__` showing up in the JavaScript but not in the HTML?
- Remove Widgets in Dashboard
- Themes VS Plugins [duplicate]
- Changing widget options via the functions.php when there are no hooks
- How do I register a stylesheet inside a WordPress widget?
- Detect if a plugin was included in a certain page
- How to get popular post from across a network?
- Are there plugins that interfere with the admin part of Rss widget?
- Flickr plugin that will display photos from multiple group pools? [closed]
- I need some direction on how to have a sidebar based on meta rather than page
- How can I reuse the WordPress search form for a custom plugin / widget?
- Multisite Widget/Content
- Passing $this->get_field_name() to javascript
- Ajax gives 400 error
- Missing argument 3 for wp_register_sidebar_widget()
- I have no idea “How change font for elements in widget?”
- Widget for adding HTML markup to a page
- How to save additional user data as part of the registration process?
- Get post values of form created by widget in sidebar
- Archive – same title for the first two posts
- How to add media field to WP_Widget form function?
- changes to widget settings not showing up in individual pages pages until they’re updated [closed]
- How to remove traces from widget during uninstallation
- Calendar Plugins – Featured Widget [closed]
- WordPress plugin subscribe2 not looking the same as before migration
- How to make WordPress customizable for clients
- Setup page on first login on multisite
- How can I inject options into an select tag inside the widget form?
- Add content to footer – above wp_footer
- Conditional tag in Widget Logic for checking if top level page or if subpage
- Trying to create a table/list of my EventBrite course listings [closed]
- Disabling plugin but wpenqueue is not available
- Related posts widget or plugin needed
- Problem since update 3.5 [duplicate]
- Call plugin with php function
- How to disable a widget when dependent plugin is inactive?
- How can I delete a wordpress widget instance?
- WordPress Apply filter in plugin causes 500 internal error
- Saving widget options from class method
- Widget’s container?
- Add SideBar/Widgets Just Below the Post
- PHP Warning: Declaration of aec_contributor_list::form() should be compatible with WP_Widget::form($instance)
- Creating a widget and missing jQuery
- Plugin showing error
- WordPress Widget Not Saving Instance
- How to display a widget on a page with no theme?
- Accessing widget information
- Setting text widget to one page only
- How to add captcha to publish widget
- jQuery slider widget similar to cnet.com
- Why aren’t my Follow Me links working?
- Is there any plugin to show number of clicks on the link?
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- co-authors plugin – inline listing
- Widgets are not displaying in the admin panel
- Can I add Short Code Of A Plugin In The Code Editor of WordPress?
- Adding custom post category to categories widget
- Change language in SiteOrigin Widgets
- elementor development – custom widget like an inner section widget
- Update widget values from ajax function
- The styles in the recent posts widgets plugin not working
- Some Widgets in the Right Side Bar and the whole Footer section is not working in a WordPress Site
- Using foreach loop for `$instance` of form and update array widget iteration
- How to disable a widget area of a specific page?
- One time call to external API in widget
- Widget display in theme
- Registered sidebar area is not shown from plugin.
- Custom content per post in widget
- Using slightly modified widget
- Hook on widget context plugin to add custom context for widget
- How to make wp multisite subdomain exist search
- Customize a widget position
- Custom Widget not Available after Plugin Installation
- Adding link on title its in description but not in title see screenshots attached
- Plugin Works, but Widget Doesn’t
- Widget Script Loads at Bottom of Page
- Use of apply_filter in plugin/widget class
- conditional tags for the output of a plugin
- Widget redirecting to home page
- Plugin won’t activate, fatal error (widget class not found)
- WordPress plugin not eching popular posts
- Trying to output a “Most visited blogs” list in wordpress multisite
- How to use template field in the Event Organiser plugin widget
- Scrolling Ads? Live scrolling widget, not random on refresh
- Is it possible to control content on different pages by checkboxing wich content is shown where on a wordpress theme page?
- Issue with customizer and widget page
- Footer option is missing in Customiser
- How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]
- Use custom Javascript for a custom Elementor Widget [closed]
- Why my widget is not visible in the WordPress theme Twenty Twenty-Three
- Hide attributes based on previous selection