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!
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,
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,