Title: [Plugin: WP-Table Reloaded] Feature Request: Filter for table caption?
Last modified: August 20, 2016

---

# [Plugin: WP-Table Reloaded] Feature Request: Filter for table caption?

 *  Resolved [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-feature-request-filter-for-table-caption/)
 * First of all, thanks for this awesome plugin. It makes it so much easier to let
   my clients manage data tables on their websites.
 * However, I have one minor request. I’ve been looking through the source for the
   plugin, and see that you’ve implemented a lot of great filters; but there seems
   to be one filter still missing: the “caption” filter. I’d like to see the following
   change made, if possible (I can submit a patch if you want). Thanks.
 * Change:
 *     ```
       $caption = '';
                   if ( !empty( $this->output_options['edit_table_url'] ) ) {
                       $edit_table_link = "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
                       $caption = "<caption style=\"caption-side: bottom; text-align: left; border:none; background: none;\">{$edit_table_link}</caption>\n";
                   }
       ```
   
 * to:
 *     ```
       $caption = '';
                   $caption_text = apply_filters( 'wp_table_reloaded_table_caption_arg', '', $table['id'], $table );
                   if ( !empty( $this->output_options['edit_table_url'] ) ) {
                       $edit_table_link = "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
                       $caption_text .= $edit_table_link;
                   }
                   if ( ! empty( $caption_text ) ) {
                       $caption = "<caption style=\"caption-side: bottom; text-align: left; border:none; background: none;\">{$caption_text}</caption>\n";
                   }
       ```
   
 * That way, as users, we’d be able to add our own captions to the tables. Do you
   think this would be possible? Thanks.
 * [http://wordpress.org/extend/plugins/wp-table-reloaded/](http://wordpress.org/extend/plugins/wp-table-reloaded/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-feature-request-filter-for-table-caption/#post-2522179)
 * Hi Curtiss,
 * thanks for your post, and the suggestion!
 * You are correct, there’s no filter for the `<caption>` tag at this time. I’m 
   not really sure why though 🙂 Might be that I just forgot it, or might be that
   I thought that it is not necessary (because you could filter the final table 
   HTML in the `wp_table_reloaded_post_output_table` hook and add it there).
    But
   the best solution likely is to just add it, as you suggest 🙂
 * I’d suggest something like this, for some more flexibility:
 *     ```
       // <caption> tag
       $caption = apply_filters( 'wp_table_reloaded_table_caption_arg', '', $table );
       $caption_style = $caption_class = '';
       if ( ! empty( $caption ) )
       	$caption_class = "wp-table-reloaded-table-caption wp-table-reloaded-table-caption-id-{$table['id']}";
       if ( ! empty( $this->output_options['edit_table_url'] ) ) {
       	if ( ! empty( $caption ) )
       		$caption .= '<br/>';
       	else
       		$caption_style = ' style="caption-side:bottom;text-align:left;border:none;background:none;"';
       	$caption .= "<a href=\"{$this->output_options['edit_table_url']}\" title=\"" . __( 'Edit', 'default' ) . "\">" . __( 'Edit', 'default' ) . "</a>";
       }
       if ( ! empty( $caption ) )
       	$caption = "<caption{$caption_class}{$caption_style}>\n{$caption}</caption>\n";
       ```
   
 * Is that ok for you?
 * I’ll add that code to the plugin then, so that it will be included in the next
   version. Meanwhile, you can just go ahead and modify the plugin file in your 
   installation (as that change will then not be lost after the update, obviously).
 * Regards,
    Tobias
 *  Thread Starter [Curtiss Grymala](https://wordpress.org/support/users/cgrymala/)
 * (@cgrymala)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-feature-request-filter-for-table-caption/#post-2522194)
 * Looks great to me. I’ll give it a shot. Thanks for the quick response.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-feature-request-filter-for-table-caption/#post-2522230)
 * Hi,
 * ok then, it’s in 🙂
 * Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: WP-Table Reloaded] Feature Request: Filter for table caption?’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-table-reloaded_f7dcd3.svg)
 * [WP-Table Reloaded](https://wordpress.org/plugins/wp-table-reloaded/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-table-reloaded/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-table-reloaded/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-table-reloaded/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-table-reloaded/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-table-reloaded/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-feature-request-filter-for-table-caption/#post-2522230)
 * Status: resolved