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
- Translate widget titles using qTranslate plugin
- 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?
- $post>ID displays wrong post ID
- How to add author details in the post sidebar?
- Video Embed in Sidebar Widget with Links to Others in Category
- Shortcode from a widget is wrapped in unwanted element
- Add a select box to all widgets
- How to avoid widgets added to sidebar on theme activation?
- Manual display of widget
- Sidebar Widget Registration without a name, how is it assigned to new named sidebar widget?
- Is there a way to allow only certain type of widgets in the sidebars?
- Display sidebar that created in functions.php
- List sidebars on a page
- wordpress widget textbox in the sidebar
- WordPress tag cloud add more links
- 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?
- Insert Widget option into mark-up with register_sidebar
- Full width layout for custom post type pages
- Adding custom html and standard widgets to sidebar
- How to add new sidebar widget area to child theme?
- 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
- different class (css) for sidebar widgets
- Need help using a filter on the default Categories widget
- How to show different widgets on different pages in a user friendly way
- How can I assign widgets from WP to appear in bbpress?
- Can you target a widget_class in a register_sidebar?
- Default widgets assignment – isn’t working
- Copy Widget Settings because of changed IDs
- Programmatically add widgets to sidebars
- How to call widget by widget’s id?
- Are widgets meant to be used outside of sidebars?
- wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls
- Show a widget as a sidebar fallback
- How to pass a special CSS class into widget li
- what is the best way to add things to a side bar
- Display posts from category in post content?
- How to register a widget when saving a post?
- Is there a way to use get_sidebar() when no widgets are activated?
- Multiple rows of footer widget areas
- What conditional to use for dynamic sidebar check?
- Hook in a sidebar widget and add some markup
- How do I exclude portrait pictures from the nextgen gallery sidebar widget?
- links to Media Library content in sidebar per page
- Upgraded to 3.3, My Widgets Disappeared
- Why is registering a sidebar for each page causing my sidebars to reset?
- activate custom sidebar widgets
- How can I detemine the parameters needed by the_widget()?
- widgets in footer?
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- My theme didn’t appear sidebar area
- How to create sidebar from “scratch”?
- Display current tag archive’s name and description in sidebar
- How can I add a prefix to titles displayed in sidebar using function.php?
- Sidebar widgets are over the content in mobile mode, how can I fix it? [closed]
- Loading scripts only if a particular shortcode or widget is present
- Use customizer or sidebar for header settings?
- Script in sidebar blocks other widget’s load
- Does current page contain widget or sidebar
- widgets_init actions not fired from functions.php’s child theme
- Active Sidebar Conditional Question?
- Can I get variable into dynamic sidebar?
- Paginate recent posts widget
- Pass widget variable to external function
- if is within sidebar [duplicate]
- how to call new widgets in sidebar in custom theme?
- Conditionally enable autoplay when using oEmbed in a custom widget
- user definable sidebar per page
- Call sidebar from a template
- 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?
- Post Thumbnails on Sidebar Widgets
- Unique widget id in sidebar
- Correct way to add a block element to sidebar layout
- How can I add multiple content-editable blocks without a plug-in?
- Putting a URL, for a preview, in a side bar
- Add a twitter feed to my WordPress website
- Add custom settings to widget areas