Title: [Plugin WP-Table Reloaded] Sorting tables with shortcodes?
Last modified: August 20, 2016

---

# [Plugin WP-Table Reloaded] Sorting tables with shortcodes?

 *  [matiuru](https://wordpress.org/support/users/matiuru/)
 * (@matiuru)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/)
 * Hello Tobias, First sorry bad english. You are a genius man!! I have a problem.
   I create a table with many colums, NAMES – GOALS – MISS – POINTS
    It is a very
   long table. I want to use the same table in differents post, in one post i want
   to show only NAMES and GOALS and want to sort automaticaly by GOALS and in descending.
   In another post I want to show only NAMES and POINTS, and order by POINTS but
   automaticaly too. Is that possible using a shortcode? Where are all the possible
   shortcodes for this plugin? The table is updated very frecuently, that´s why 
   I want to use the same table for all posts.
 * MANY THANXS and sorry my english.
 * Matías.-

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212088)
 * Hi Matías,
 * thanks for your question.
 * Yes, you can achieve this with an additional Shortcode parameter. That parameter
   is the “hide_columns” and “show_columns” parameter.
    All parameters are explained
   in the documentation at [http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/documentation/](http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/documentation/).
 * The parameter for the automatic sorting on the second column is “datatables_customcommands”(
   that parameter is basically the same as filling the “Custom Commands” textfield
   in the “DataTables Features” section on the “Edit” screen, just on a per-Shortcode-
   basis).
    You will want to give that parameter the value
 *     ```
       'aaSorting': [[1,'asc']]
       ```
   
 * So, in total, you will likely be using a Shortcode like this:
 *     ```
       [table id=1 hide_columns="all" show_columns="1,3" datatables_customcommands="'aaSorting': [[1,'asc']]" /]
       ```
   
 * This will (with the special value “all” first hide all columns and then only 
   show the the first and third columns (that number is what you will need to change
   to get the GOALS or POINTS column).
    The customcommands parameter should then
   set the initial sorting.
 * Best wishes,
    Tobias
 *  Thread Starter [matiuru](https://wordpress.org/support/users/matiuru/)
 * (@matiuru)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212118)
 * Thanx for the inmediat response. The shortcode you suggest is not working, it
   shows not in the order, and at the bottom of the table it shows this:
 * ]” /]
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212130)
 * Hi,
 * argh, yes… As it seems, it is not possible that arguments in a Shortcode also
   use the `]` character, as WordPress seems to think that this marks the end of
   the Shortcode.
 * Please try again with this one, which escapes the `]` with a `\`. Just an idea,
   but likely it does not work either.
 *     ```
       [table id=1 hide_columns="all" show_columns="1,3" datatables_customcommands="'aaSorting': \[\[1,'asc'\]\]" /]
       ```
   
 * If that does not work either, you will need to use the version of the Shortcode
   without that parameter:
 *     ```
       [table id=1 hide_columns="all" show_columns="1,3" /]
       ```
   
 * and additionally paste the command
 *     ```
       "aaSorting": [[1,'asc']]
       ```
   
 * into the “Custom Commands” textfield in the “DataTables Features” section on 
   the “Edit” screen of the table.
    This will have the same effect. However, this
   will mean that the large table (with all columns) will automatically be sorted
   for the second column…
 * Regards,
    Tobias
 *  Thread Starter [matiuru](https://wordpress.org/support/users/matiuru/)
 * (@matiuru)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212141)
 * Perfect! That works, but I have a problem, when i display the complete table 
   with all the columns it is order by the secondone, is the any way to disable 
   the “aaSorting”: [[1,’asc’]] with the shortcode?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212152)
 * Hi,
 * that’s what I meant with my last sentence in the previous post.
 * And after checking the code again: Yes, fortunately, you can disable that again
   with the Shortcode parameter 🙂
    Just add the parameter with an empty value to
   the Shortcode which displays the large table, so that it becomes
 *     ```
       [table id=1 datatables_customcommands="" /]
       ```
   
 * This should work as there are no `]` in the parameter.
 * Regards,
    Tobias
 *  Thread Starter [matiuru](https://wordpress.org/support/users/matiuru/)
 * (@matiuru)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212318)
 * Hi Tobias, I want to add another thing to this, I want to be shown only the first
   10 files, like the top ten. Is that possible? Thanx!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212319)
 * Hi,
 * you could either use the pagination feature for this (then one can still view
   the other ones, but they are hidden initially), or you use the “show_rows” and“
   hide_rows” Shortcode parameters (see the documentation) to only show those ten
   rows. You could also hide rows through the “Hide row” feature on the “Edit” screen.
 * (As a side note: If you use this, you will need to uncheck the “Cache Table Output”
   checkbox!)
 * Regards,
    Tobias
 *  [knicee](https://wordpress.org/support/users/knicee/)
 * (@knicee)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212335)
 * Tobias,
 * I think this will solve the question i asked you from my other post about “rankings”
   staying frozen =)

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

 The topic ‘[Plugin WP-Table Reloaded] Sorting tables with shortcodes?’ 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/)

 * 8 replies
 * 3 participants
 * Last reply from: [knicee](https://wordpress.org/support/users/knicee/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-table-reloaded-sorting-tables-with-shortcodes/#post-2212335)
 * Status: not resolved