If you were to add var_dump($params);
to the top of your callback you’d notice that it contains references to both the sidebar name and the sidebar ID. You can use those to control when this runs, provided you know the name or ID.
function widget_params( $params ) {
if ('Main Sidebar' === $params[0]['name']) {
// do something
}
return $params;
}
add_filter( 'dynamic_sidebar_params', 'widget_params' );
Related Posts:
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Determining a Widget Instance and Sidebar Location?
- Woocommerce Product Category Widget – hide categories that have no products in stock [closed]
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Disable widgets on specific posts
- Excluding specific widgets from default sidebar class
- Dynamically add content to an existing widget area
- Issue understanding and using WordPress filters and actions
- Filter Text from sidebar widget?
- How to append custom text to the output of ‘categories widget’?
- Distinguish between different widgets of the same type
- Programmatically add widgets to sidebars
- Loading scripts only if a particular shortcode or widget is present
- Limit number of Widgets in Sidebars
- Give Editor Access To Sidebar
- Where is the content of widgets stored in mysql table
- Translate widget titles using qTranslate plugin
- Get number of widgets in sidebar
- Extend WordPress 3.8 Site Activity Dashboard Widget to include more comments
- How to influence the information displayed on widget inside wp-admin
- How Do I Add Custom CSS To Only Certain Widgets
- How to hook into unregistering a widget instance?
- Add the sidebar/widget editor to the post edit screen?
- Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?
- Add filter to blogroll 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
- How to add author details in the post sidebar?
- How to add a filter to all widget output
- Randomize widgets displayed in my sidebar [duplicate]
- Video Embed in Sidebar Widget with Links to Others in Category
- Shortcode from a widget is wrapped in unwanted element
- Remove All Widgets from Sidebar
- Add div class to only one widget
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- Add class to before_widget for all widgets with a dropdown and a counter
- Unregistering a Sidebar in Child Theme
- Add a select box to all widgets
- Problems with the sidebar args and wp_list_bookmarks
- How to avoid widgets added to sidebar on theme activation?
- Ban certain widgets from certain sidebars
- Manual display of widget
- Sidebar Widget Registration without a name, how is it assigned to new named sidebar widget?
- is_active_sidebar() Always Returns False
- Call sidebar from a template
- How could a Widget behave differently depending on sidebar
- Unfiltered html in widget title not working
- Adding classes to dynamic sidebar
- Is there a way to allow only certain type of widgets in the sidebars?
- Widget Area: Modify $param[‘xy’] from widget-$n
- Display sidebar that created in functions.php
- Create variable from widget instance
- Save/update widget outside admin panel [closed]
- How to insert widget areas specific to certain pages (or posts, etc.)?
- List sidebars on a page
- Why use dynamic_sidebar() conditionally?
- wordpress widget textbox in the sidebar
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- More flexible sidebar and widget management
- WordPress tag cloud add more links
- WordPress widget new instance creates content duplicates
- dynamic_sidebar() returns false in admin section
- duplicate sidebar
- How to check if searchform.php is being included as widget?
- Is it possible to enqueue a script from a widget method (of extended WP_Widget object)?
- the_widget() and widget’s ID
- How to get sidebar’s content inside admin-ajax?
- Removing custom widget area WordPress 4.4 [closed]
- Insert Widget option into mark-up with register_sidebar
- Full width layout for custom post type pages
- How to “pair” two widgets side by side in one sidebar [closed]
- Trying to wrap around first word of multiple word strings with a widget_title() filter, only works on two word strings and not more than two
- Adding custom html and standard widgets to sidebar
- Dynamic Sidebars On Multiple Subpages
- How to add new sidebar widget area to child theme?
- Cannot save widgets in custom sidebars
- Check which registered sidebar a widget is added to
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- Add individual tag to widget title in sidebar
- Can WordPress Read Its Own RSS Feed?
- different class (css) for sidebar widgets
- Can’t see widget areas in my customizer
- Need help using a filter on the default Categories widget
- Passing values from a widget to a function within a plugin
- 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 assign widgets from WP to appear in bbpress?
- How can I get the first section of a page 100% width, while the rest will have a sidebar? [closed]
- Replace a menu with widget or a custom template file programmatically
- Trying to create dynamic widget area using post ID
- Can you target a widget_class in a register_sidebar?
- How to create pagination for homepage with widgetized area?
- How can I inject html after the [x]th widget inside a Sidebar? [duplicate]