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:
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- Conditionally enqueue a widget’s script/stylesheet in HEAD (only when present on page!)
- Plugin upgrading: Widget settings
- Need to create a Theme demo site that features multiple themes
- Adding a widget programmatically
- Delete Custom Dashboard Widgets
- Override dynamic_sidebar() in plugin?
- Is dynamic forms/entries possible in Widget?
- Has anyone been able to get the aweber plugin to work
- How to create a widget or plugin to add custom content to my website?
- Pages with 2 Columns
- Custom Widget outputs the input but doesn’t save anything inside the textarea
- Custom Widget Creating PHP Exception When Placed In Its Own PHP File
- register child class in another plugin
- Conditional Display of Links in Widgets
- How to Get Admin Settings for a widget when using the_widget() with custom widget
- How to unregister a widget from a child theme
- WordPress multiple widget in single plugin
- Created Widget Not Showing up on Admin Panel
- Setting up widgets in wordpress with a unique ID for the after_title argument
- How to exclude a widget from page 1 of a paginated post
- how can i limit the number of instances for my widget
- Dashboard Widget Form
- Admin Dashboard with Custom Tab for Client
- WordPress author details plugin/widget
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- WAMP to XAMPP WordPress transfer
- How to check if you are on widget.php page?
- The plugin generated 3 characters of unexpected output during activation
- Theme’s default styles are overriding my plugin’s custom CSS
- Rotate Widgets or Content Blocks every x sec/min
- Multi language site [closed]
- How to style the RSS wordpress?
- How can I disable widget from being visible on some pages?
- How to display more than one instance for a widget?
- Custom random quote widget breaks when used in multiple sidebars
- Hooking in to replace the Sidebar/Widget areas
- Do widget options need to be escaped widget()?
- Ajax contact form widget plugin data not insert in database
- How to hide CSS by default and show on button press
- In the archive widget, how do I sort in between two years?
- Widgets Scripts don’t load – but load when I reload the page
- How to add wp visual editor in a custom widget?
- WordPress Widget – Saving multidimensional arrays into $instance
- Custom plugin appears outside of the sidebar container
- Char limit on custom blog-post form? [closed]
- How do I use wp_editor() in widget form?
- How to reorder and display a feed to be chronological?
- Hide certain widgets from specific user roles in admin
- How to add Wrapper Div/container element around WordPress Widget Content
- Disabling plugin but wpenqueue is not available
- Related posts widget or plugin needed
- How do I find out what is in control over a certain part of a website?
- Best practice for including plugin output in a template without using shortcode?
- Custom widget doesn’t save values from dropdown box
- Register Script in Plugin Widget
- Add Shortcode tag in Widget/Sidebar
- How to create wordpress widget that is fixed position on the home page
- How to handle forms from sidebar widgets – Processing $_POST variables using get_field_name()
- Short messages widget [closed]
- jQuery Click event is not fired at all
- Widget for specific category
- get_term_meta returns false in widget
- My widget won’t update its values when save is clicked
- Widget where it can make changes to the container
- Widget content turns up before title
- Extend a plugin to include a widget option
- Is there a Image Gallery which will load all my posted Images like twitter’s image grid?
- Modify pages widget and make a plugin?
- wp_footer hook running twice
- Table of contents (TOC) plugin is not showing header tag
- How can I display selected content from a seperate database in an Activity style widget?
- How to fetch WordPress database values in JavaScript widget
- RSS Feed on WordPress showing code (hypertext) in articles titles
- What is the right way to populate a dropdown from MySql?
- Shortcode generated widget to appear on same line as heading text and button
- How do I keep children of certain parent menus expanded by default on a sidebar?
- Registered sidebar area is not shown from plugin.
- Widget logic using woocommerce product category
- How to display widget in front end?
- Widget outputs the value but doesn’t save anything inside the textarea
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Using Widget Logic to place menu on multiple pages?
- Plugin Works, but Widget Doesn’t
- Show widget location borders for development
- Cannot access variables within a widget
- adding image in the header of my dev widget
- Use of apply_filter in plugin/widget class
- jquery conflict with widget page
- Plugin: Unable to Save the Image Alignment Option to Display in the Widget in the Sidebar
- Template from scratch: Sidebars not showing widget
- How to develop an extension for a simple form post and post back? [closed]
- How to add homepage Widget?
- What are the downsides of using bootstrap in plugin development?
- What can I do to customize a widget provided with this plugin? from where have I to start?
- Content expands beyond its column container [closed]
- Issue with customizer and widget page
- Footer option is missing in Customiser
- Use custom Javascript for a custom Elementor Widget [closed]
- Why my widget is not visible in the WordPress theme Twenty Twenty-Three