If you want to display a fallback sidebar, you can do the following. If you want to decide which widget gets displayed, then idk.
Create 2 sidebars. Example: sidebar
and fallback-sidebar
.
In your template you can use:
if(is_active_sidebar( 'sidebar' )){
dynamic_sidebar( 'sidebar' );
} else {
dynamic_sidebar( 'fallback-sidebar' );
}
If you just trying to determine if a particular sidebar is active find the id of the sidebar and use:
if(is_active_sidebar( $sidebarID )){
//do stuff here
}
This might work: (Sorry im not at a pc i can test it at)
if(is_active_sidebar( $sidebarID )){
the_widget('WP_Widget_Archives', $instance, $args);
}
//I believe this will attempt to display the WP_Widget_Archives widget, if the
//sidebar with the id of $sidebarID is inactive.
Related Posts:
- Limit number of Widgets in Sidebars
- Give Editor Access To Sidebar
- Where is the content of widgets stored in mysql table
- Get number of widgets in sidebar
- Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?
- Get sidebar parameters (before_widget, before_title, etc.) from within a widget
- Different widgets on different page templates?
- Widgets not displaying in theme customizer
- $post>ID displays wrong post ID
- Register multiple sidebars
- Determining a Widget Instance and Sidebar Location?
- Randomize widgets displayed in my sidebar [duplicate]
- Video Embed in Sidebar Widget with Links to Others in Category
- Remove All Widgets from Sidebar
- Add div class to only one widget
- Unregistering a Sidebar in Child Theme
- Problems with the sidebar args and wp_list_bookmarks
- Ban certain widgets from certain sidebars
- Manual display of widget
- is_active_sidebar() Always Returns False
- Call sidebar from a template
- How could a Widget behave differently depending on sidebar
- Adding classes to dynamic sidebar
- Create variable from widget instance
- Save/update widget outside admin panel [closed]
- How to insert widget areas specific to certain pages (or posts, etc.)?
- Why use dynamic_sidebar() conditionally?
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- More flexible sidebar and widget management
- WordPress widget new instance creates content duplicates
- the_widget() and widget’s ID
- Removing custom widget area WordPress 4.4 [closed]
- How to “pair” two widgets side by side in one sidebar [closed]
- Dynamic Sidebars On Multiple Subpages
- Cannot save widgets in custom sidebars
- Check which registered sidebar a widget is added to
- Disable widgets on specific posts
- Excluding specific widgets from default sidebar class
- Can WordPress Read Its Own RSS Feed?
- Can’t see widget areas in my customizer
- Dynamic sidebar based on category
- Widgets not activated alert after using get_sidebar()
- How to show different widgets on different pages in a user friendly way
- Show widget differently depending on if it’s in the sidebar or footer
- How can I get the first section of a page 100% width, while the rest will have a sidebar? [closed]
- Trying to create dynamic widget area using post ID
- How to create pagination for homepage with widgetized area?
- Dynamically add content to an existing widget area
- How can I inject html after the [x]th widget inside a Sidebar? [duplicate]
- Programmatically add widgets to sidebars
- Programmatically add widgets to sidebars
- Override WordPress Widget CSS Classes?
- Dynamic Sidebar and XHTML Validity?
- register_sidebar fails when using a include within functions.php
- Update widget form after drag-and-drop “only specific plugin”
- Recent Comments from Specific Category Widget
- Different sidebars not changing
- how to add the same Widget twice to a sidebar?
- Filter Text from sidebar widget?
- Different widgets in sidebar on sub-children pages?
- Display posts from category in post content?
- My widget not printing before_widgets and after widgets
- Is there a way to use get_sidebar() when no widgets are activated?
- Output column number according to active sidebars
- Check if widget is inside sidebar with PHP
- What conditional to use for dynamic sidebar check?
- Any available action to add content before and after sidebar?
- Distinguish between different widgets of the same type
- links to Media Library content in sidebar per page
- Why is registering a sidebar for each page causing my sidebars to reset?
- How to Catch Last Widget box From Same Widget Area?
- changing the style of sidebar
- How can I detemine the parameters needed by the_widget()?
- widgets in footer?
- WordPress Local to Live and The Missing Widgets!
- Need to delete the sidebar widget area and have the page a full page rather than just have a blank widget area
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- Need two sidebar (right and left)in Twenty Seven theme
- Reposition the widget sidebar in Appearance->Widgets
- How to get sidebar widgets in leftsidebar template
- Add Social Media icon widget to customizer
- Loading scripts only if a particular shortcode or widget is present
- Handling dozens of sidebars
- three sidebars showing without call
- Add sidebar in inner pages
- Inkness theme sidebar
- How can I get the sidebar id on the current page?
- Automatically hide Widgets that would lengthen page
- user definable sidebar per page
- Show or hide custom menu widget in side bar conditionally
- Custom tabs widget don’t work in google chrome, is blocked, do not change the tabs. Why?
- Single Widget Multi Sidebar
- Post Thumbnails on Sidebar Widgets
- Correct way to add a block element to sidebar layout
- How to hide sidebar widgets in all pages except Hompage?
- How to completely remove the sidebar? [closed]
- Subpages menu on sidebar plus widgets
- How to inject a virtual widget (i.e. without adding it to the database) to the sidebar
- Can’t edit the widgets sidebar or footer