Extension 3: Changing the Table Shortcode

January 23rd, 2010 by Tobias Leave a reply »

My second Extension to WP-Table Reloaded was actually pretty short and simple, so I decided to present another short one to make up for that :-) So, here you will see how you can change the used Shortcode from [[table id=1 /]] to e.g. [data id=1 /] or [ranking id=1 /].

To get started with WP-Table Reloaded Extensions, you should read the introduction and follow the included instructions. You will also find links to the other presented Extensions there.

Changing the name of the used Shortcode could be useful for several use cases:

  • You want it to be in your native language (i.e. for German: Tabelle instead of table).
  • You are already (or want to) use the table for something else.
  • Your generated tables resemble something specific, i.e. a set of data, or a ranking.

And it really is simple! All you need is this code:

 * Changes Shortcode for WP-Table Reloaded from [[table id=N /]] to [[ranking id=N /]]
 * @author Tobias Baethge
 * @see https://tobias.baethge.com/2010/01/extension-3-changing-the-table-shortcode/
function wp_table_reloaded_change_table_shortcode( $shortcode ) {
    return 'ranking';
add_filter( 'wp_table_reloaded_shortcode_table', 'wp_table_reloaded_change_table_shortcode' );

The code will change the Shortcode from [[table id=1 /]] to [[ranking id=1 /]]. Of course you can change ‘ranking’ to anything you like in the code above!

This code just needs to be copied into the file “wp-table-reloaded-extensions.php”, created according to these instructions (after the Plugin Header comment, but before the closing PHP bracket ?>). Then, just activate the new plugin “WP-Table Reloaded Extensions”, if you haven’t. That’s it! :-)

If you like this series of Extensions, I’m happy about any feedback, and especially about further suggestions!

Previous posts in this series that might interest you: