WordPress – modify existing plugin function with add_filter


I am relatively new to WordPress and using custom filters and hooks.
My site uses the TablePress plugin. But I need to be able to add the html attribute of


To all tables created through the plugin. The only way to do so is to

There’s not direct way to add this, but you could e.g. use the tablepress_table_tag_attributes filter hook that can be used to change the attributes of the element. The filter is defined in class-render.php

as per https://wordpress.org/support/topic/table-role/#post-9665599

The class-render.php mentioned is below:

$table_attributes = apply_filters( 'tablepress_table_tag_attributes', $table_attributes, $this->table, $this->render_options );
$table_attributes = $this->_attributes_array_to_string( $table_attributes );


In my functions.php file I have added:

add_filter( 'tablepress_table_tag_attributes' , 'add_presentation_role', 11);
function add_presentation_role() {
    // return ?

But i am struggling to see what I need to put inside my function. Anything I put in breaks my website or results in a blank page. To confirm I would like to add the the role attribute so my tables update from

<table id="tablepress-{ID}" class="tablepress tablepress-id-{ID}">


<table id="tablepress-{ID}" class="tablepress tablepress-id-{ID}" role="presentation">
, , odd_duck 1 year 2020-07-23T07:10:23-05:00 0 Answers 39 views 0

Leave an answer