![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/fc5a88b4ad7d3b756a36f70316d40880-87a1c39.jpg)
Hi there,
need to add the widget id as an "id" attribute. How to achive that?
<div class="tm-widget uk-panel widget_text text-12">[...]</div>
Should become
<div class="tm-widget uk-panel widget_text text-12" id="text-12">[...]</div>
Found that, but when to use this to that the id is available?
beans_add_attribute('beans_widget_panel', 'id', beans_widget_shortcodes('{id}'));
Thanks!
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hi Andrea,
To be able to add the correct id for each widget, you have to use a callback to make sure your code run when the widget is called. Likeley Beans has a dynamic filter {$markup_id}_attributes
which filters all attributes of each markup. So you can run the following snippet:
add_filter( 'beans_widget_panel_attributes', 'example_modify_widget_panel_attributes' );
function example_modify_widget_panel_attributes( $attributes ) {
return array_merge( array( 'id' => beans_widget_shortcodes( '{id}' ) ), (array) $attributes );
}
Note that I have intentionally used array_merge()
to insure that the id is the first attribute output for conventional sake.
Have fun,
![](https://beanscommunity.wpenginepowered.com/wp-content/uploads/beans/images/c70294be72623e3f8995ee4832f8d065-87a1c39.jpg)
Hi Andrea,
To be able to add the correct id for each widget, you have to use a callback to make sure your code run when the widget is called. Likeley Beans has a dynamic filter {$markup_id}_attributes
which filters all attributes of each markup. So you can run the following snippet:
add_filter( 'beans_widget_panel_attributes', 'example_modify_widget_panel_attributes' );
function example_modify_widget_panel_attributes( $attributes ) {
return array_merge( array( 'id' => beans_widget_shortcodes( '{id}' ) ), (array) $attributes );
}
Note that I have intentionally used array_merge()
to insure that the id is the first attribute output for conventional sake.
Have fun,